Re: [Vala] Gee.Testcase
- From: Simon Busch <morphis gravedo de>
- To: vala-list gnome org
- Subject: Re: [Vala] Gee.Testcase
- Date: Thu, 26 Jul 2012 09:54:46 +0200
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/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]