-
Notifications
You must be signed in to change notification settings - Fork 9
0.7.x manual 09.API
JCUnit already has API which enables users to generate test suites programmatically, but it doesn't support some important features like FSM etc.
Following is a diagram that illustrates (current) relationships between entities that you need to know to build a TestSuite object without relying on JCUnit's test runner.
+-----------------+ +--------------------+
| List< TestCase >| |Map< String,Object >|
+-----------------+ +--------------------+
| |
A A
| |
+-----------------+ +---------+ +-----------+ +-----+
|TestSuite.Builder|- - ->|TestSuite|<>---->|TestCase |<>----->|Tuple|
+-----------------+ +---------+ 1 * +-----------+ 1 1 +-----+
1| |Type type |
| +-----------+
|
| +---------------------------+
+-------------->|TestSuite.Builder.Predicate|
* +---------------------------+
And following is a code example to use this API.
001: TestSuite testSuite = new TestSuite.Builder()
002: .addFactor("factor1", 1, 2, 3)
003: .addBooleanFactor("boolean")
004: .addByteFactor("byte")
005: .addCharFactor("char")
006: .addShortFactor("short")
007: .addIntFactor("int")
008: .addLongFactor("long")
009: .addFloatFactor("float")
010: .addDoubleFactor("double")
011: .addStringFactor("string")
012: .addEnumLevels("enum", TestCase.Type.class)
013: .addConstraint(new TestSuite.Builder.Predicate() {
014: public boolean apply(Tuple in) {
015: return !in.get("factor1").equals(1);
016: }})
017: .enableNegativeTests()
018: .build();
019:
020: for (TestCase each : testSuite) {
021: ...
022: for (Predicate violatedConstraint : TestSuite.getViolatedConstraints(each) {
023: ...
024: }
025: }
What we want to do for FSM is something like following.
.addFsmFactor(
"flyingSpaghettiMonster",
new Fsm.Builder()
.addState( ... )
.build()
)
(t.b.d.)
Copyright 2013 Hiroshi Ukai.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.