Dynamically adding test methods

2 views
Skip to first unread message

Alexander Gladysh

unread,
Sep 9, 2009, 7:40:12 PM9/9/09
to fluint-di...@googlegroups.com
Hi, list!

I'm Alexander Gladysh, one of authors of Lua Alchemy library
http://code.google.com/p/lua-alchemy. Lua Alchemy allows user to run
Lua code inside Flash VM.

I'm working on integration of pure Lua tests into our fluint test
suite. I'd like to see these tests integrated as separate test methods
inside TestCase.

To do so, I need to be able to extend TestCase in run-time with test
methods I'd receive from Lua script I load. I did not found a way to
do this in fluint 1.1.1.

I've tried to declare my TestCase-derived class as dynamic and to add
test* methods in its constructor, but that does not work. It seems
that test methods are enumerated too early -- buildTestCollection is
called in the constructor of the base class.

Any suggestions?

Alexander.

Michael Labriola

unread,
Sep 9, 2009, 8:18:57 PM9/9/09
to Fluint Discussions

Alexander,

I believe there is a getter in 1.1.1 called getTests() which will
return a reference to the testCollection. The thing I would try is
adding your tests to this collection manually after your data returns.

Mike

On Sep 9, 6:40 pm, Alexander Gladysh <aglad...@gmail.com> wrote:
> Hi, list!
>
> I'm Alexander Gladysh, one of authors of Lua Alchemy libraryhttp://code.google.com/p/lua-alchemy. Lua Alchemy allows user to run

Alexander Gladysh

unread,
Sep 10, 2009, 3:54:54 AM9/10/09
to fluint-di...@googlegroups.com
Mike,

On Thu, Sep 10, 2009 at 04:18, Michael Labriola<malab...@gmail.com> wrote:
> I believe there is a getter in 1.1.1 called getTests() which will
> return a reference to the testCollection. The thing I would try is
> adding your tests to this collection manually after your data returns.

Thank you, but, unfortunately, it seems that this method was
introduced after 1.1.1 release:

http://code.google.com/p/fluint/source/browse/tags/release-1.1.1/fluint/src/main/flex/net/digitalprimates/fluint/tests/TestCase.as

I'd like to avoid building fluint from SVN... but it looks like I'd
have to resort to this.

However, the resulting code is a bit on the ugly side. Perhaps I'm
missing something?

public dynamic class TestLuaBased extends CommonLuaAlchemyTestCase
{
private function buildTestCollection():XMLListCollection
{
// Had to copy-paste this from TestCase sources. :-(
}

private function refreshTestCollection():void
{
var collection:ICollectionView = getTests();
var cursor:IViewCursor = collection.createCursor();

// Clear collection
while (!cursor.afterLast)
{
cursor.remove();
}

var newTestMethods:XMLListCollection = buildTestCollection();
var newCursor:IViewCursor = newTestMethods.createCursor();

while (!newCursor.afterLast)
{
cursor.insert(newCursor.current);
newCursor.moveNext();
}
}

public function TestLuaBased()
{
//RunLuaToFillTestCases();
refreshTestCollection();
}
}

Alexander.

Reply all
Reply to author
Forward
0 new messages