EgTest: quick & easy unit tests

"David Leppik [email protected] [junit]" <[email protected]> Fri, 10 Mar 2017 17:29:24 -0600
Newsgroups gmane.comp.java.junit.user
Message-ID <[email protected]>
I have a new framework which combines unit tests and documentation in source code. The goal is to make unit testing "excuse-free:" i.e. so simple that they become the lazy way to spot-check code, while ensuring that examples in Javadoc are automatically tested.


This is a complementary way to write certain simple tests, rather than a full-on replacement for hand-writing JUnit tests.




https://github.com/dleppik/EgTest




A quick example; this would be found in a main (non-test) Java file:


@Eg(given = {"1", "2"}, returns = "3")
@Eg(given = {"1", "Integer.MAX_VALUE"}, returns = "Integer.MIN_VALUE")
static int add(int a, int b) {
    return a + b;
}


The above annotations show up in Javadoc and they produce a JUnit test which tests the assertions on the add method.


Any feedback would be extremely welcome. This is early enough that it's not too late to change the syntax or nomenclature if there's a better way to go about it.




	-Dave


--
David Leppik                                     http://www.leppik.net/david/blog/
[email protected]


"As a computer shrinks, the gravitational force that its components exert on one another becomes stronger and eventually grows so intense that no material object can escape."
-- Scientific American, Nov 2004, p. 56




------------------------------------
Posted by: David Leppik <[email protected]>
------------------------------------