Forums

Naming tests

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Naming tests

Postby Charles » Sat Aug 04, 2012 8:46 pm

I have added basic support for naming tests in the Cobra parser:
class X

test fill
ml = MultiList<of int>(4, 3, 2).fill(5, [1, 2, 3, 4, 5, 6, 7, 8])
assert ml.toString == ...
ml1 = MultiList<of Pair<of int>>([2, 2]).fill([Pair<of int>(0, 2), Pair<of int>(1, 3)])
ml2 = MultiList<of Pair<of int>>([2, 2], [Pair<of int>(0, 2), Pair<of int>(1, 3)])
assert ml1.equals(ml2)

test cloneAndTranspose
ml = MultiList<of int>([3, 4, 2], for i in 24 get i+3)
assert ml.clone.transpose.equals(ml.permute([2, 1, 0]))

Eventually we'll get into options like running a specific test, excluding tests, parameterized tests, etc. For now I just wanted to stub out this syntax so we could start using it.

Enjoy.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Naming tests

Postby nerdzero » Thu Oct 25, 2012 3:36 pm

So, I've been using this syntax and it's nice but one thing I am wishing for is someway to share data between tests. They key is I don't want anything that is used exclusively for testing to end up in a final "release build" of an assembly. I've just assumed that something like 'setup' and 'teardown' were absent from Cobra by design but maybe that's not the case. Any thoughts on this?
nerdzero
 
Posts: 286
Location: Chicago, IL

Re: Naming tests

Postby Charles » Fri Oct 26, 2012 12:17 am

Cobra has the -include-tests:no option which currently strips out the unit tests. My plans include providing a TestSupport attribute that would mark classes and methods that only existed for test support and could therefore be stripped out as well:

class FakeColor has TestSupport

...

There would also be compile-time error checking that non-test code could not call into test code.

As far as .setUp and .tearDown go, I haven't given them as much thought.
Charles
 
Posts: 2515
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 100 guests

cron