TestSuite
open class TestSuite : Test
| kotlin.Any | |
| ↳ | junit.framework.TestSuite |
A TestSuite is a Composite of Tests. It runs a collection of test cases. Here is an example using the dynamic test definition.
TestSuite suite= new TestSuite();
suite.addTest(new MathTest("testAdd"));
suite.addTest(new MathTest("testDivideByZero"));
Alternatively, a TestSuite can extract the tests to be run automatically. To do so you pass the class of your TestCase class to the TestSuite constructor.
TestSuite suite= new TestSuite(MathTest.class);
This constructor creates a suite with all the methods starting with "test" that take no arguments.
A final option is to do the same for a large array of test classes.
Class[] testClasses = { MathTest.class, AnotherTest.class }
TestSuite suite= new TestSuite(testClasses);
Summary
Public constructors |
|
|---|---|
<init>()Constructs an empty TestSuite. |
|
|
Constructs a TestSuite from the given class. |
|
|
Constructs a TestSuite from the given class with the given name. |
|
|
Constructs an empty TestSuite. |
|
|
Constructs a TestSuite from the given array of classes. |
|
|
Constructs a TestSuite from the given array of classes with the given name. |
|
Public methods |
|
|---|---|
| open Unit |
Adds a test to the suite. |
| open Unit |
addTestSuite(testClass: Class<out TestCase!>!)Adds the tests from the given class to the suite |
| open Int |
Counts the number of test cases that will be run by this test. |
| open static Test! |
createTest(theClass: Class<*>!, name: String!). |
| open String! |
getName()Returns the name of the suite. |
| open static Constructor<*>! |
getTestConstructor(theClass: Class<*>!)Gets a constructor which takes a single String as its argument or a no arg constructor. |
| open Unit |
run(result: TestResult!)Runs the tests and collects their result in a TestResult. |
| open Unit |
runTest(test: Test!, result: TestResult!) |
| open Unit |
Sets the name of the suite. |
| open Test! |
Returns the test at the given index |
| open Int |
Returns the number of tests in this suite |
| open Enumeration<Test!>! |
tests()Returns the tests as an enumeration |
| open String |
toString() |
| open static Test! |
Returns a test which will fail and log a warning message. |
Public constructors
<init>
TestSuite(theClass: Class<*>!)
Constructs a TestSuite from the given class. Adds all the methods starting with "test" as test cases to the suite. Parts of this method were written at 2337 meters in the Hueffihuette, Kanton Uri
<init>
TestSuite(
theClass: Class<out TestCase!>!,
name: String!)
Constructs a TestSuite from the given class with the given name.
<init>
TestSuite(vararg classes: Class<*>!)
Constructs a TestSuite from the given array of classes.
| Parameters | |
|---|---|
classes |
Class<*>!: TestCases |
<init>
TestSuite(
classes: Array<Class<out TestCase!>!>!,
name: String!)
Constructs a TestSuite from the given array of classes with the given name.
Public methods
addTestSuite
open fun addTestSuite(testClass: Class<out TestCase!>!): Unit
Adds the tests from the given class to the suite
countTestCases
open fun countTestCases(): Int
Counts the number of test cases that will be run by this test.
createTest
open static fun createTest(
theClass: Class<*>!,
name: String!
): Test!
...as the moon sets over the early morning Merlin, Oregon mountains, our intrepid adventurers type...
getName
open fun getName(): String!
Returns the name of the suite. Not all test suites have a name and this method can return null.
getTestConstructor
open static fun getTestConstructor(theClass: Class<*>!): Constructor<*>!
Gets a constructor which takes a single String as its argument or a no arg constructor.
run
open fun run(result: TestResult!): Unit
Runs the tests and collects their result in a TestResult.
setName
open fun setName(name: String!): Unit
Sets the name of the suite.
| Parameters | |
|---|---|
name |
String!: the name to set |
tests
open fun tests(): Enumeration<Test!>!
Returns the tests as an enumeration
toString
open fun toString(): String
| Return | |
|---|---|
String |
a string representation of the object. |
warning
open static fun warning(message: String!): Test!
Returns a test which will fail and log a warning message.