Super simple behavior-driven development style test writer for Jmm.
jmm get github.com/jminusminus/simplebdd
The default test runner for Jmm.
Create a test file.
// My_test.java
package path.to.package;
import github.com.jminusminus.simplebdd.Test;
public class My_test extends Test {
public static void main(String[] args) {
My_test test = new My_test();
test.run();
}
public void testThatThisIsTrue() {
this.should("return that boolean matches boolean");
this.assertEqual(true, true);
}
}
Run the jmm test command.
jmm test ./My_test.java
Read the results.
github.com.jminusminus.jmmexample.Helloworld_test
✓ should return the congratulations text
✓ 1 tests complete
To create a test extend the Test class and create an instance of it in the main method.
public class My_test extends Test {
public static void main(String[] args) {
My_test test = new My_test();
test.run();
}
}
Any method that starts with "test" will be executed by SimpleBDD.
public void test_name() {
// Test code
}
Method called before any test is executed.
public void before() {
// Prep-code
}
Method called before each test is executed.
public void beforeEach() {
// Prep-code
}
Method called after all tests have executed.
public void after() {
// Cleanup code
}
Method called after each test has executed.
public void afterEach() {
// Cleanup code
}
import github.com.jminusminus.simplebdd.Test;
Runs the test by calling each method that begins with "test" outputting the results to System.out
. The command will exit with the number of failed tests.
public static void main(String[] args) {
My_test test = new My_test();
test.run();
}
Adds a description of what the preceding code "should" do.
public void test_boolean_is_boolean() {
this.should("return that boolean matches boolean");
}
Used to test if two types are the same. Supported types are Short, Int, Long, Float, Double, Boolean, Char and String.
public void testName() {
this.assertEqual(true, true);
}
Used to test if two types are NOT the same. Supported types are Short, Int, Long, Float, Double, Boolean, Char and String.
public void testName() {
this.assertNotEqual(false, true);
}