Skip to main content

Parallelism and Logging

When tests are run in parallel, it's not easy to figure out what exactly is happening at execution time. The tester needs to know the sequence of the test suite and individual tests.

Generally, logs provide this information. Most of the popular languages achieve parallelism using "Threads". Hence it is a matter of utmost importance that Thread Identifier should find a place in the logs.

Log generated when test executed in parallel WITHOUT thread identifier

INFO  28-11-2018 17:13:34,140 [TestNG] i.a.t.AndroidTestNGExampleTest: Enter initDefaultDesiredCapabilities
INFO 28-11-2018 17:13:34,140 [TestNG] i.a.t.AndroidTestNGExampleTest: Setting up Desired Capabilities
INFO 28-11-2018 17:13:34,139 [TestNG] i.a.t.IOSTestNGExampleTest: Enter initDefaultDesiredCapabilities
INFO 28-11-2018 17:13:34,140 [TestNG] i.a.t.IOSTestNGExampleTest: Setting up Desired Capabilities
INFO 28-11-2018 17:13:34,139 [TestNG] SeeTestProperties: --------- END ---------
INFO 28-11-2018 17:13:34,142 [TestNG] SeeTestProperties: Exit loadInitProperties() ...
INFO 28-11-2018 17:13:34,142 [TestNG] i.a.t.WebTestNGExampleTest: Enter initDefaultDesiredCapabilities
INFO 28-11-2018 17:13:34,142 [TestNG] i.a.t.WebTestNGExampleTest: Setting up Desired Capabilities
INFO 28-11-2018 17:13:34,150 [TestNG] i.a.t.IOSTestNGExampleTest: Device Query = @os='ios'

Log generated when test executed in parallel WITH thread identifier

INFO  28-11-2018 17:13:34,140 [TestNG:11] i.a.t.AndroidTestNGExampleTest: Enter initDefaultDesiredCapabilities
INFO 28-11-2018 17:13:34,140 [TestNG:11] i.a.t.AndroidTestNGExampleTest: Setting up Desired Capabilities
INFO 28-11-2018 17:13:34,139 [TestNG:12] i.a.t.IOSTestNGExampleTest: Enter initDefaultDesiredCapabilities
INFO 28-11-2018 17:13:34,140 [TestNG:12] i.a.t.IOSTestNGExampleTest: Setting up Desired Capabilities
INFO 28-11-2018 17:13:34,139 [TestNG:13] SeeTestProperties: --------- END ---------
INFO 28-11-2018 17:13:34,142 [TestNG:13] SeeTestProperties: Exit loadInitProperties() ...
INFO 28-11-2018 17:13:34,142 [TestNG:13] i.a.t.WebTestNGExampleTest: Enter initDefaultDesiredCapabilities
INFO 28-11-2018 17:13:34,142 [TestNG:13] i.a.t.WebTestNGExampleTest: Setting up Desired Capabilities
INFO 28-11-2018 17:13:34,150 [TestNG:12] i.a.t.IOSTestNGExampleTest: Device Query = @os='ios'

As we can see from above, the second snippet of the log is much clearer to a user as it clearly gives an indication that  "AndroidTestNGExampleTest" is executed in thread "11".

There is also more clarity to the user how the tests were executed by the run-time engine.