Testly: Perform some test to your code!

User projects written in or related to FreeBASIC.
zerospeed
Posts: 227
Joined: Nov 04, 2005 15:29

Testly: Perform some test to your code!

Postby zerospeed » Dec 23, 2006 2:11

Hello Boys and Girls!

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)

Testly is a simple, minimal testing library aimed to programmers using FreeBASIC
to implement agile techniques like TDD (test driven development)


Its offered as static lib to be linked against your test suites.

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()


And this is the output generated by testly:
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


There are two packages available:
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):
*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.


Notes
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
Last edited by zerospeed on Feb 09, 2008 14:38, edited 4 times in total.
v1ctor
Site Admin
Posts: 3795
Joined: May 27, 2005 8:08
Location: SP / Bra[s]il
Contact:

Postby v1ctor » Dec 24, 2006 2:41

Great job, just rebuilt it to make sure i didn't break anything in the last commits.

It seems much more "sane" and simpler to use than CUnit that's too "C"-centric (no wonder). Don't expect too many users though, BASICers aren't really used to unit testing as in other languages :).

This reminded me that we really need a repository page in fb.net to host libraries and such.. ow..
zerospeed
Posts: 227
Joined: Nov 04, 2005 15:29

Postby zerospeed » Dec 26, 2006 3:52

v1ctor wrote:Great job, just rebuilt it to make sure i didn't break anything in the last commits.


You didn't, I was happing problems and getting a minimal sample when saw your commit about new wasn't initializing UDT members.

v1ctor wrote:It seems much more "sane" and simpler to use than CUnit that's too "C"-centric (no wonder). Don't expect too many users though, BASICers aren't really used to unit testing as in other languages :).


I know, guess is a bad practice not "test" your code properly. One of the reason many think BASIC isn't a good programming language.

v1ctor wrote:This reminded me that we really need a repository page in fb.net to host libraries and such.. ow..


That will be great!, I was thinking in code some "fblib" tool that can list the repository libs and download/update them with just fblib testly, extracting the static lib to lib/platform or geenrating the dyanmic imports based on .def files, and unpacking the include files into inc folder...

Just and idea, of course.

Thanks for your comments,

Zero
zerospeed
Posts: 227
Joined: Nov 04, 2005 15:29

Postby zerospeed » Dec 30, 2006 17:37

Updated project to version 0.2

Please refer to first post about information, download links and changelog.

All feedback is welcome.

Later,

Zero
zerospeed
Posts: 227
Joined: Nov 04, 2005 15:29

Postby zerospeed » Feb 13, 2007 13:40

Hello Forum!

Testly made some progress (0.2.1 version) and home moving to Google Code!

Also code is now MIT License compatible, you could could feel safe using it ;-)

Please refer to the first post for detailed information about it.

Don't hesitate on leave comments and suggestions.

Zero
zerospeed
Posts: 227
Joined: Nov 04, 2005 15:29

Postby zerospeed » Aug 13, 2007 22:52

Been quiet... but stable!

I've bumped Testly to version 0.2.4

Testly use features available since 0.17 -lang fb

The updates includes precompiled version for 0.18.1 (which actually didn't require tweaking).

Seems right do this announcement now that 0.18.1 is in pre-release.

If anyone can test it alos on Linux, I'll really appreciate it ;-)

See the first post of this thread for links and details.

Later!

Zero
cha0s
Site Admin
Posts: 5317
Joined: May 27, 2005 6:42
Location: Illinois
Contact:

Postby cha0s » Aug 13, 2007 23:18

I gotta take the time to get this set up and give it a full chance. Hopefully this week! I love test test testing modular code.. hehe.
zerospeed
Posts: 227
Joined: Nov 04, 2005 15:29

Updated Version!

Postby zerospeed » Feb 09, 2008 14:40

I just released version 0.3.0 of Testly!

I've updated the first message of this thread with the included changes.

(Bumping this) :-)

Later,
Zero

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 4 guests