Close menu
Open menu

The SimBank Installation Verification Test

This basic test logs on to Galasa SimBank and examines an account.

Exploring the SimBankIVT test class

Even without any prior knowledge of Galasa, if you know a little Java, you will have no trouble understanding the flow of logic in and the SimBankIVT test class.

The class is first annotated with @Test - informing the framework that a method or (as in this case) a class is a test.

Next at the beginning of the test class proper, several Galasa Managers are declared via annotations, together with their corresponding public interfaces - @ZosImage, @Zos3270Terminal and so on. Using the imageTag="SIMBANK" argument with @ZosImage allows you to associate an instance of a Manager with a set of configuration properties. In this example, the associated configuration properties are the ones that are set in the file, as described in the Running the SimBank tests using the CLI documentation.

public class SimBankIVT{

    public IZosImage image;

    public ITerminal terminal;

    public IArtifactManager artifacts;

    public IHttpClient client;

    public ICoreManager coreManager;

Galasa will instantiate these objects - they are indeed, the Managers mentioned earlier.

Note that as a general principle, any objects, classes or methods that you wish to interact with the Galasa test framework should be declared as public.

Next, a test method testNotNull is defined - when executed, this tests and demonstrates that Galasa has started the required Managers.

public void testNotNull() {
    //Check all objects loaded

Each line includes an assertion that states that an instance of a Manager should not be null. If one or more of these assertions is not true, then the test will fail, alerting you to the fact that one or more Managers has not been initialized correctly.

Finally, the main test method itself - checkBankIsAvailable() - is defined, and calls coreManager.registerConfidentialText to register the application password to the confidential text filtering service. This service replaces occurrences of registered phrases from log output with a numbered shield - e.g. *1**. In a generated log, a completed password field might look like:

Userid ===> IBMUSER  Password ===> *1**

Then, a sequence of method calls chained off terminal.waitForKeyboard() enables Galasa to sign into SimBank using its session manager. It demonstrates using the following methods:

  • positionCursorToFieldContaining(<string>) - which as its name implies, positions the cursor to a field containing a specific label
  • tab() - which presses the TAB key in the application under test
  • type(<string>) - where a sequence of characters are typed into an input field
  • enter() - where the ENTER key is pressed
public void checkBankIsAvailable() throws Exception {
        //Logon through the session manager

These methods are available via the imported Zos3270Terminal Manager, which was written by a specialist and made available by the Galasa framework to anyone who needs to write a test that uses such an abstraction. It supports a fluent style, allowing its methods to be chained in a natural and easily-understandable fashion.

Two assertThat() assertions then confirm that the test has arrived on its intended screen, verified by the presence of a single occurrence of each of the strings SIMPLATFORM MAIN MENU and BANKTEST.

//Assert that the session manager has a bank session available
assertThat(terminal.retrieveScreen()).containsOnlyOnce("SIMPLATFORM MAIN MENU");

The test proceeds to open the banking application, pressing the PF1 key and clearing the screen, before tabbing to an input field and entering the name of the BANK transaction:

//Open banking application

Finally, three assertions confirm that the test has arrived at its destination screen.

//Assert that the bank menu is showing
assertThat(terminal.retrieveScreen()).containsOnlyOnce("Options     Description        PFKey ");
assertThat(terminal.retrieveScreen()).containsOnlyOnce("BROWSE      Browse Accounts    PF1");
assertThat(terminal.retrieveScreen()).containsOnlyOnce("TRANSF      Transfer Money     PF4");

If any assertion failed, then the whole test would be marked as a failed test.