Re: [Vala] Gee.Testcase



Simon,

Thanks for the heads up I'll play around with your framework. I ended
up coping the testcase class from gee and it worked, just seems odd it
had to be included, maybe the vapi is wrong. I hope at some point
there will be a defacto unit testing library.

On Thu, Jul 26, 2012 at 12:54 AM, Simon Busch <morphis gravedo de> wrote:
Am 25.07.2012 22:07, schrieb Joseph Montanez:

So I ran across this blog:
http://esite.ch/2012/06/26/writing-tests-for-vala/

I gave it a try and I can't seem to compile. I tried compiling the
lastest libgee and changing my package config to local.

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
valac --pkg gee-1.0 main.vala TestExample.vala

TestExample.vala:1.21-1.32: error: The type name `Gee.TestCase' could
not be found
class TestExample : Gee.TestCase {


Using Gee.TestCase is ok but in my case I missed support for testing async
methods. Thats why I created libfsotest which enables you to test async
methods too. See [0] for the library and the following lines for a small
example:

public class TestCase0 : FsoFramework.Test.TestCase
{
    public TestCase0()
    {
        base( "TestCase0" );

        add_async_test( "AsyncWithTimeout",
                        cb => test_async_with_timeout( cb ),
                        res => test_async_with_timeout.end( res ),
                        4000 );
    }

    public async void test_async_with_timeout() throws GLib.Error,
AssertError
    {
        bool done = false;

        Timeout.add_seconds( 3, () => {
            done = true;
            test_async_with_timeout.callback();
            return false;
        } );
        yield;

        Assert.is_true( done );
    }
}

public static int main( string[] args )
{
    Test.init( ref args );

    TestSuite root = TestSuite.get_root();
    root.add_suite( new TestCase0().get_suite() );

    Test.run();

    return 0;
}

regards,
Simon

[0]:
http://git.freesmartphone.org/?p=cornucopia.git;a=tree;f=libfsotest;h=0b5e92f57a243e6265f3ac15b11ec03ca621851e;hb=HEAD


--
Simon Busch - http://mm.gravedo.de/blog/
_______________________________________________
vala-list mailing list
vala-list gnome org
https://mail.gnome.org/mailman/listinfo/vala-list



-- 
Joseph Montanez
Web Developer
Gorilla3D
Design, Develop, Deploy



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]