The next article will explain how to create a batch which includes several tests.
For your convenience please find the following video guide below:
setBatch is a helpful Applitools Eyes command, that provides us the ability to gather multiple tests and run them together.
After setting your API key, you can go ahead and add the next commands:
eyes.setBatch (new batchInfo("login")
After creating a new batch info command, you can go ahead and specify the string with the name of the batch (e.g "login").
Note that by using this method the results of your tests will be displayed as two separate batches:
The reason the tests appear separated has to do with the method written before each test:
In order to cluster the tests together, we need to change a few commands in our test code:
First, we need to create a batch info object before each of the tests, and reference the object to each of our tests.
To do that, we need to create a BeforeClass method, that will run before the TestClass, and set it as a static method called setBatch.
Next, instead of just naming the string, as we did before, we need to store it in a batch field variable, which we need to create following this step:
Next, we can go down to the previous setBatch command and create a few little changes:
Before the last change: After the last change:
After making those changes and running the test, we will see the next results in our test results:
As you can see, instead of having two separate test results as before, the tests are now batched together under the same result.
In unique cases, where you need to aggregate tests from different instances, processes or machines (with potentially different batchInfo objects) Applitools Batch ID command can be used.
The batch ID is one of the batch's optional parameters (other than batch name for example). Setting the same Batch ID to each of the relevant tests which you wish to aggregate together will group them under the same batch.
Note: Make sure to generate a unique batch ID for each of your batches, which will prevent irrelevant tests to be grouped under the same batch.
Java
/* Create the batch object and set the ID */
BatchInfo b = new BatchInfo("BATCH_NAME_HERE");
b.setId("SOME_UNIQUE_ID");
/* Set the batch to Eyes */
eyes.setBatch(b);
/* Set a new batch to eyes. */
eyes.setBatch("BATCH_NAME_HERE", "SOME_UNIQUE_ID");
''' You need to make sure to import the BatchInfo class '''
from applitools.common.config import BatchInfo
''' Create the batch object and set the ID '''
b = BatchInfo("BATCH_NAME_HERE")
b.id_ = "SOME_UNIQUE_ID"
''' Set the batch to Eyes '''
eyes.batch = b
# Create the batch object and set the ID
b = BatchInfo.new "BATCH_NAME_HERE"
b.id = "SOME_UNIQUE_ID"
# Set the batch to Eyes
eyes.batch = b
/* Create the batch object and set the Name */
let my_batch = BatchInfo(name: "my_batch")
/* Set the batch to Eyes */
eyes.batch = my_batch;
/* Create the batch object and set the ID */
BatchInfo b = new BatchInfo("BATCH_NAME_HERE");
b.Id = "SOME_UNIQUE_ID";
/* Set the batch to Eyes */
eyes.Batch = b;