Page 1 of 1

Naming tests

PostPosted: Sat Aug 04, 2012 8:46 pm
by Charles
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.

Re: Naming tests

PostPosted: Thu Oct 25, 2012 3:36 pm
by nerdzero
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?

Re: Naming tests

PostPosted: Fri Oct 26, 2012 12:17 am
by Charles
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.