ounit
Contains functions for testing. Invokes all functions with prefix test
and checks expected and actual values, counts execution time
Functions
assertEquals(expected, actual)
— checks that two values are equal
assertFalse(actual)
— checks that value is false (equals 0)
assertNotEquals(expected, actual)
— checks that two values are not equal
assertSameType(expected, actual)
— checks that types of two values are equal
assertTrue(actual)
— checks that value is true (not equals 0)
runTests()
— executes tests and returns information about it's results
use ounit
def testAdditionOnNumbers() {
assertEquals(6, 0 + 1 + 2 + 3)
}
def testTypes() {
assertSameType(0, 0.0)
}
def testFail() {
assertTrue(false)
}
println runTests()
/*
testTypes [passed]
Elapsed: 0,0189 sec
testAdditionOnNumbers [passed]
Elapsed: 0,0008 sec
testFail [FAILED]
Expected true, but found false.
Elapsed: 0,0001 sec
Tests run: 3, Failures: 1, Time elapsed: 0,0198 sec
*/