In this blog post we combine several of the Boozang features to run it as a test engine, using an external CSV file as a driver.
Even though the platform was designed to run as master, there are times when it’s desirable to completely keep both test automation logic and user data external to the platform.
An example of this would be when you are maintaining a spreadsheet of acceptance tests that consist of a large number of simplistic tests, such as access policy tests. Another example could be when doing data provisioning or test data initiation. Regardless of real-life example, it serves to highlight the versatility of the request data type and plug test-case action.
This blog post will be fairly technical and show-case how we can combine several of the features in Boozang to externalize logic and data in CSV files. It is recommended for those unfamiliar with Boozang to first checkout our forum posts
In this example, we have a master list of acceptance tests, testlist.csv, as seen below
Test Userid Run BAC1 admin m2.t7 BAC2 user m2.t8 BAC3 admin m2.t8
As you can see, we have the following columns
- Test: Acceptance test id
- Userid: Userid for the user that runs the test
- Run: The Boozang test id
We also have a list of users, userlist.csv, as seen below
_key username password admin johnny johnnypwd user anna annapwd
The file simply contains username and passwords. The first column “_key” will show Boozang that this is matrix data, which means rows can be accessed like
jsonRow = userMatrix["admin"]
We start by copying both files to a Dropbox folder and noting down the external URLs. We could course simply copy this data into Boozang, but that would defeat the idea somewhat of having it run as a slave system.
Loading the main engine in Boozang
We start by defining two new “Request data” variables using the Boozang data tab, “$test.test_case_list” and “$test.user_lookup_list”. You can see in below screenshot how it looks when they are loaded in Boozang.
The next step is to create a master “Engine” test case that drives the data loop. Let’s call it “Engine CSV loop”. Makes sure that under “Data tab -> Loop data” you select the “$test.test_case_list”.
This will loop the test-case over the CSV rows, and the current data row will be available in the “$loop” data handle. In order to extract the “username” and “password” from the user matrix, use the following code snippet
console.log($loop.Test); console.log($loop.Run); $test.tmp=$test.user_lookup_list[$loop.Userid]
Now press play and see what happens. If everything is alright the following should be outputted in the application console.
Creating the tests
console.log("I am running TC1 using $parameter data: "); console.log($parameter);
console.log("I am running TC2 using $parameter data: "); console.log($parameter);
Note down the ids of each test, and update the “testlist.csv” accordingly. In my example, the tests are: m2.t7 and m2.t8.
Tying it together
Now it’s time to update the “engine CSV loop” to call the right test. Add a plug-test-case action and pick any test. Replace the contents of the “Goto Test case” field with
Now, it will read the test id from the “Run” column in the testlist.csv” row. Also, update the “Value” column for the plug-test case action and make sure the user-data is sent
Text-editor mode: $test.tmp
The resulting test should look as follows
Running the code
Now, press play and see what happens. If everything was setup correct (fingers crossed), the following should be outputted in the application console