O'Reilly logo

TestNg Beginner's Guide by Varun Menon

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – running test methods in parallel

Perform the following steps to create test methods in parallel:

  1. Create new class with the name SampleTestMethod under the test.parallelism package and replace the following code in it:
    package test.parallelism; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; public class SampleTestMethod { @BeforeMethod public void beforeMethod(){ long id = Thread.currentThread().getId(); System.out.println("Before test-method. Thread id is: "+id); } @Test public void testMethodsOne() { long id = Thread.currentThread().getId(); System.out.println("Simple test-method One. Thread id is: "+id); } @Test public void testMethodsTwo() { long id ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required