Browse Source

Testframework add example "testsuite"

JNI-96
heck 5 years ago
parent
commit
1239928664
  1. 25
      test/java/foundation/pEp/jniadapter/test/framework/examples/testsuite/Makefile
  2. 34
      test/java/foundation/pEp/jniadapter/test/framework/examples/testsuite/TestMain.java

25
test/java/foundation/pEp/jniadapter/test/framework/examples/testsuite/Makefile

@ -0,0 +1,25 @@
include ../Makefile.conf
TEST_UNIT_NAME=testsuite
JAVA_CLASSES = \
TestMain.class \
# Use the test framework
JAVA_CLASSES += $(JAVA_CLASSES_FRAMEWORK)
.PHONY: compile run test clean
all: compile
$(MAKE) run
run: compile
cd $(JAVA_CWD);$(JAVA) $(JAVA_PKG_BASENAME).$(TEST_UNIT_NAME).TestMain
compile: $(JAVA_CLASSES)
%.class: %.java
cd $(JAVA_CWD);pwd;javac $(JAVA_PKG_BASEPATH)/$(TEST_UNIT_NAME)/$<
clean:
rm -f $(JAVA_CLASSES)

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

@ -0,0 +1,34 @@
package foundation.pEp.jniadapter.test.framework.examples.testsuite;
import static foundation.pEp.jniadapter.test.framework.TestLogger.*;
import foundation.pEp.jniadapter.test.framework.*;
class TestSuiteTestContext extends AbstractTestContext {
String name;
@Override
public void init() throws Throwable {
name = "UnitTestFrameWorkWithoutAName";
}
}
class TestMain {
public static void main(String[] args) throws Exception {
TestSuite.setVerbose(true);
new TestUnit<TestSuiteTestContext>("Unit Test 1", new TestSuiteTestContext(), ctx -> {
log("Unit Test 1 " + ctx.name);
ctx.name = "new name";
}).add();
new TestUnit<TestSuiteTestContext>("Unit Test 2", new TestSuiteTestContext(), ctx -> {
log("Unit Test 2 " + ctx.name);
}).add();
new TestUnit<TestSuiteTestContext>("Unit Test 3", new TestSuiteTestContext(), ctx -> {
log("Unit Test 3 Failing " + ctx.name);
int x = 4 / 0;
}).add();
TestSuite.run();
}
}
Loading…
Cancel
Save