JavaFX: Bringing Rich Experiences To All the Screens Of Your Life

Profile: desktop, common

Overview

JavaFX Unit Test base class for creating declarative, fluent, behavior-driven tests. Tests can be run individually by using the perform() method, or executed in larger suites by using a classpath traversing test runner (in-progress).

Here is an example of a simple test:

 import org.jfxtras.test.Expect.*;
 Test {
     say: "Sequences.max should return the maximum value"
     do: function() {Sequences.max([3, -1, 4, 0])}
     expect: equalTo(4)
 }.perform();
 

For more information about writing tests, please refer to the test examples in the JavaFX source code, or see my blog: http://steveonjava.wordpress.com/

Variable Summary

accessnametypeCan ReadCan InitCan WriteDefault Valuedescription
public-initassumeAssumption[]

Conditions which must be met for this test to be run.

Conditions which must be met for this test to be run. This is particularly useful for parameterized testing where a large set of tests are setup, but only a limited set are valid scenarios.

 
public-initcleanupfunction():Void

Cleanup function called after the test execution has completed.

public-initdofunction():Object

Main execution block of the unit test.

Main execution block of the unit test. This should perform whatever test steps are required, and return a value that can be checked by the expect clause. Any exceptions thrown in this block will be counted towards a test failure unless they are defined in expectException.

 
public-initexpectExpectation[]

The main form of declarative assertions, this is a list of Expectations that if not true will fail the test.

The main form of declarative assertions, this is a list of Expectations that if not true will fail the test. For a full list of built-in expectations, see Expect.

 
public-initexpectExceptionFXClassType

For tests that are designed to test failure conditions, this can be set to the type of the expected exception.

For tests that are designed to test failure conditions, this can be set to the type of the expected exception. As a convenience, all built-in exceptions inherit org.jfxtras.lang.JFXObject#getJFXClass() so there is no reflection call required.

 
public-initsayString

Verbal requirement for what this test should accomplish.

Verbal requirement for what this test should accomplish. For nested tests this will be concatenated with whatever the enclosing test says.

 
public-inittestTest[]

A list of subtests that will be run after this test, but before cleanup.

A list of subtests that will be run after this test, but before cleanup. A common usage of this is to group related tests with an outer test that has no expectations. In this case the outer test will not get counted towards the results.

 

Inherited Variables

Function Summary

public perform() : Test

Single test runner action.

Single test runner action. This should be called for all tests and will be intelligently disabled if a suite runner is used instead. return The current test instance to facilitate runs of suites

Returns
Test
 

Inherited Functions