What is the JUnit Plug-in

The JUnit plug-in is meant for those tests that are interface-independent. It is also a plug-in in it's simplest form. Some examples of using the JUnit plug-in might include:

  • Create a tag to manipulate or compare files.
  • Compare two variables.
  • Create an object that can be used in the context instead of using individual values from and external data source
  • Connect to a remote sever and start up a service.
  • Connect to a remote sever and search for a resource.

JUnit Tags Syntax Reference

<ju-session/>The JUnit plug-in provided session tag
<ju-assert-equals/>checks the equality of two values.
<ju-assert-true/>Checks that provided Expression is true.
<ju-assert-not-null/>Checks that the given value is not null.
<ju-assert-null/>Checks that the given value is null.

JUnit Tags

ju-session tag

This is the JUnit Session Tag. It has attributes outside from the Session Tag Common Attributes

ju-assert-equals tag

This tag is used to compare two values:

Attribuate NameAttribuate Description
expectedThe expected value
actualThe actual value
msgThe message to be printed out if the test fails

Some examples:

                                                                                                    
<ju-assert-equals functionId="Compare 1 against 1"
    expected="1"
    actual="1"/>
<ju-assert-equals functionId="Compare one against two"
    expected="one"
    actual="two"
    msg="Numbers as Words"/>
                    

ju-assert-true tag

This tag is used to do a boolean compare:

Attribuate NameAttribuate Description
testAn expression with a boolean results.
msgThe message to be printed out if the test fails

Some examples:

                                                                                                    
<ju-assert-true functionId="Compare 1 against 1"
    test="${1 == 1}"/>
<jelly:set var="counter" value="4"/>
<ju-assert-true functionId="Compare a context variable with 4"
    test="${counter == 4}"/>
                    

ju-assert-not-null tag

This tag is used to check that a provided value is not null.

Attribuate NameAttribuate Description
valueThe value to check for null
msgThe message to be printed out if the test fails

Example:

                                                                                                    
<ju-assert-not-null functionId="Check that a non-existent context variable is not null"
    value="${nonExistentVariable}"
    msg="value was null!"/>
                    

ju-assert-null tag

This tag is used to check that a provided value is null.

Attribuate NameAttribuate Description
valueThe value to check for null
msgThe message to be printed out if the test fails

Example:

                                                                                                    
<ju-assert-null functionId="Check that a context variable is null"
    value="${someVariable}"
    msg="value was null!"/>