Browse Source

Testframework omprove Examples

JNI-96
heck 5 years ago
parent
commit
fcab9ca3ab
  1. 4
      test/java/foundation/pEp/jniadapter/test/framework/examples/ctxmembers/TestMain.java
  2. 6
      test/java/foundation/pEp/jniadapter/test/framework/examples/helloworld/TestMain.java
  3. 6
      test/java/foundation/pEp/jniadapter/test/framework/examples/testsuite/TestMain.java

4
test/java/foundation/pEp/jniadapter/test/framework/examples/ctxmembers/TestMain.java

@ -18,9 +18,11 @@ class CtxMembersTestContext extends AbstractTestContext {
@Override
public void init() throws Throwable {
log("=== OUTPUT FROM TEST CONTEXT INIT BEGIN ===");
log("HelloWorldTestContext: init() called");
correct = new ExampleCtxMember(true);
name = "UnitTestFrameWorkWithoutAName";
log("=== OUTPUT FROM TEST CONTEXT INIT END ===");
}
}
@ -29,7 +31,9 @@ class TestMain {
TestUnit test = new TestUnit<CtxMembersTestContext>("Hello World",new CtxMembersTestContext() , ctx -> {
// do stuff using the context
// Test FAILS on unhandled exception, otherwise SUCCESS
log("=== OUTPUT FROM THE TEST ITSELF BEGIN ===");
log("Hello World from: " + ctx.name);
log("=== OUTPUT FROM THE TEST ITSELF END ===");
});
TestUtils.sleep(2000);

6
test/java/foundation/pEp/jniadapter/test/framework/examples/helloworld/TestMain.java

@ -17,19 +17,25 @@ class TestMain {
new TestUnit<HelloWorldTestContext>("Hello World1",new HelloWorldTestContext() , ctx -> {
// do stuff using the context
// Test FAILS on unhandled exception, otherwise SUCCESS
log("=== OUTPUT FROM THE TEST ITSELF BEGIN ===");
log("OK Hello World 1 from: " + ctx.name);
log("=== OUTPUT FROM THE TEST ITSELF END ===");
}).run();
new TestUnit<HelloWorldTestContext>("Hello World2",new HelloWorldTestContext() , ctx -> {
// do stuff using the context
// Test FAILS on unhandled exception, otherwise SUCCESS
log("=== OUTPUT FROM THE TEST ITSELF BEGIN ===");
log("OK Hello World 2 from: " + ctx.name);
log("=== OUTPUT FROM THE TEST ITSELF END ===");
}).run();
new TestUnit<HelloWorldTestContext>("Hello World3",new HelloWorldTestContext() , ctx -> {
// do stuff using the context
// Test FAILS on unhandled exception, otherwise SUCCESS
log("=== OUTPUT FROM THE TEST ITSELF BEGIN ===");
log("Failing Hello World 3 from: " + ctx.name);
log("=== OUTPUT FROM THE TEST ITSELF END ===");
throw new RuntimeException();
}).run();
}

6
test/java/foundation/pEp/jniadapter/test/framework/examples/testsuite/TestMain.java

@ -16,17 +16,23 @@ class TestMain {
// TestSuite.setVerbose(true);
new TestUnit<TestSuiteTestContext>("Unit Test 1", new TestSuiteTestContext(), ctx -> {
log("=== OUTPUT FROM THE TEST ITSELF BEGIN ===");
log("Unit Test 1 " + ctx.name);
ctx.name = "new name";
log("=== OUTPUT FROM THE TEST ITSELF END ===");
}).add();
new TestUnit<TestSuiteTestContext>("Unit Test 2", new TestSuiteTestContext(), ctx -> {
log("=== OUTPUT FROM THE TEST ITSELF BEGIN ===");
log("Unit Test 2 " + ctx.name);
log("=== OUTPUT FROM THE TEST ITSELF END ===");
}).add();
new TestUnit<TestSuiteTestContext>("Unit Test 3", new TestSuiteTestContext(), ctx -> {
log("=== OUTPUT FROM THE TEST ITSELF BEGIN ===");
log("Unit Test 3 Failing " + ctx.name);
int x = 4 / 0;
log("=== OUTPUT FROM THE TEST ITSELF END ===");
}).add();
TestSuite.run();

Loading…
Cancel
Save