For some programs and libs I code often I need to test that it will be backward compatible with previous versions, and also that I'm doing things right, and not break things :-P
For this, I was using a hacked unit testing framework I made (the forum link)
Now FreeBASIC allow us do a bit more things, and also have learned a bit from using Unit Tests in Ruby language.
So... I'm presenting you... Testly! (Version 0.3.0 - 2008-02-09)
Its offered as static lib to be linked against your test suites.Testly is a simple, minimal testing library aimed to programmers using FreeBASIC
to implement agile techniques like TDD (test driven development)
A sample on how your suites looks like:
Code: Select all
#include once "testly.bi"
namespace Suite1
sub before_each()
end sub
sub after_each()
end sub
sub test1()
assert_true(1=1)
assert_true(1=0)
end sub
sub test2()
assert_false(1<5)
assert_equal(0,0)
assert_equal(1,2)
assert_string_equal("uno", "dos")
end sub
sub test3()
assert_true_error(true)
assert_true_error(1>5)
end sub
sub register() constructor
add_suite(Suite1)
add_test(test1)
add_test(test2)
add_test(test3)
end sub
end namespace
run_tests()
There are two packages available:Started
FFE
Failures and Errors:
Suite 1 with error:
Failed suite setup.
Suite 1, test 1 failed:
examples/simple_test.bas:14 - {1=0} is not true.
Suite 1, test 2 failed:
examples/simple_test.bas:18 - {1<5} is not false.
Suite 1, test 2 failed:
examples/simple_test.bas:20 - expected {2} but was {1}
Suite 1, test 3 with error:
examples/simple_test.bas:25 - {1>5} is not true.
Suite 1 with error:
Failed suite teardown.
Finished in 0.000 seconds.
1 suites, 3 tests, 7 assertions, 3 failures, 3 errors
Version: 0.3.0
Source: testly-0.3.0.zip (32KB)
Precompiled (win32): testly-0.3.0-lib-win32.zip (11KB)
What's new? (the usual changelog):
Notes*0.3.0* (2008-02-09)
* Refactoring Time!
* Removed Setup/Teardown in favor for a flexible support:
before_all -> works like setup (executed prior all the tests for that suite)
before_each -> executed before each test
after_each -> the opposite of before_each
after_all -> works like teardown, get executed after all the tests and the
last after_each
* Assertions ending with '_error' will exit the test sub if fail
(there is no point continue testing, a error is something fatal).
* Removed test that are redundant (now we have better coverage).
* add_suite and add_test were coded as macro to simplify suite/test
registration.
Testly takes advantage of techniques and features only available in the latest SVN builds.
Also, was only tested on Windows, but I'm not using platform specific functions (so could be crossplatform).
Important!: Now Testly and ServiceFB are hosted at Google Code. Please drop your Issues (bug reporting) or download directly from there!
Hope that other could find it useful and simple to use, not hesitate to comment or give suggestions about it.
Thanks to all the FB forum members that answered my questions since day 1, and also the FB core team members, specialy v1ctor for creating this powerful compiler!
Later,
Zero