JBoss.orgCommunity Documentation

Chapter 5. Writing Tests using MMAdmin

JUnit testing framework is integrated into the MMAdmin, so you can write regression tests and run tests in the JUnit style. To write a test,

  1. start a method name which begins with "testxxxx()"

  2. use method body to write actual test. Method body can contain any MMAdmin based script using Admin API and JDBC commands

  3. finally use “assertions” to validate results.

For example:

	execute("select * from table");

	// make sure you have 100 rows


	execute("select * from table");

	// defines the all the values you are expecting
	String[] expected ={
		{"col1[string]", "col2[int]"},
		{"VALUE1", "100"}
	// make sure your results match to expected

// now actually run the above defined tests

In the above example, “testCountRows”, made connection to a Teiid system and issued a query and made sure that certain table has required number of rows. Where as “testResults” asserted that results match to a certain set of pre-built results.

Note the “runTests()” call at the end of the script, as this is the call which triggers the execution of the tests defined in the script. There are various types asserts you can use in your scripts, for the all the available assert types please refer to Assertion Library