Creating or customizing a test script
A test script is a Java class that automates a single test scenario, which contains one or more test cases.
The test cases hold the logic to perform storefront actions by combining tasks from the page objects in a specific order.
All of your test scripts are structured similarly. These actions are numbered in the following
sample test script and defined below it.
// 1-) Import the task libraries for use in this test script
import com.ibm.commerce.qa.aurora.page.AuroraFrontPage.<nameOfPageObject>;
//Declare a new test scenario called SampleTest which contains one or more test case methods.
//All test scenario classes must extend AbstractAuroraSingleSessionTests.
/*
* Scenario: SampleTest
* Details: A sample test script that demonstrates how to use the Storefront Test Automation Engine.
*/
public class SampleTest extends AbstractAuroraSingleSessionTests {
/**
* 2-) an annotation is added to setup the data file mechanism, including selecting the
* data file based on the class name, and setting up the datablock.
*/
protected final String dataFileName = "data/SampleTest_Data.xml";
/**
* Perform setup operations such as initializing the test harness and setting the data file that will be used.
* @throws Exception
*/
public void setUp() throws Exception {
// 2-) Set the data file that will be used.
setDataFile(dataFileName);
// 3-) Start the Selenium server.
test.doSetUp();
}
/**
* 4-) Description of this test case. There are often multiple test cases in a test script.
* @throws Exception
*/
public void testCompleteShopFlow() throws Exception {
//Set the location in the data file for this test case by specifying a test node and one of its data blocks.
setDataLocation("testCompleteShopFlowNode", "testCompleteShopFlowDataBlock");
//Open the storefront in a browser
Store.openStore();
//The tasks needed to perform this test case will be called here.
}
/**
* Perform tear down operations such as stopping the Storefront Test Automation Engine.
* @throws Exception
*/
public void tearDown() throws Exception {
// 5-) Sign out of the store. Note: This is only necessary if the store was signed in to during a test case.
Header.clickLogoutButton();
// 6-) Stop the Selenium server.
test.doTearDown();
}
}
Every test script is composed of similar actions:
- The libraries that are needed to run the test cases are imported.
- The data file for the test scenario being automated is defined and set.
- The Selenium server is started.
- The test cases are run.
- If one of the test cases signs in to the storefront, it is signed out of.
- The Selenium server is stopped.
Procedure
- In the development environment, go to the test bucket directory where you want to add a test script, to or customize an existing test script. This directory is in the src directory of your test bucket project.
- Do one of the following steps:
What to do next
Review the test scripts in the Aurora-Tests test bucket project and use their contents as a guide to write your new test script. Import the Aurora-Tests into your development environment.