Skip to content
This repository has been archived by the owner on Feb 19, 2019. It is now read-only.
/ simplebdd Public archive

Super simple behavior-driven development style test writer

License

Notifications You must be signed in to change notification settings

jminusminus/simplebdd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Test

Package: github.com.jminusminus.simplebdd

Build Status

Stability: 1 - Stable

Super simple behavior-driven development style test writer for Jmm.

Install

jmm get github.com/jminusminus/simplebdd

github.com.jminusminus.simplebdd.Test

The default test runner for Jmm.

Usage

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

Extend Test

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();
    }
}

test_xxx()

Any method that starts with "test" will be executed by SimpleBDD.

public void test_name() {
    // Test code
}

before()

Method called before any test is executed.

public void before() {
    // Prep-code
}

beforeEach()

Method called before each test is executed.

public void beforeEach() {
    // Prep-code
}

after()

Method called after all tests have executed.

public void after() {
    // Cleanup code
}

afterEach()

Method called after each test has executed.

public void afterEach() {
    // Cleanup code
}
import github.com.jminusminus.simplebdd.Test;

void run()

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();
}

void should(String should)

Adds a description of what the preceding code "should" do.

public void test_boolean_is_boolean() {
    this.should("return that boolean matches boolean");
}

boolean assertEqual(Object a, Object b)

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);
}

boolean assertNotEqual(Object a, Object b)

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);
}

About

Super simple behavior-driven development style test writer

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages