Home | History | Annotate | Download | only in thread
      1 package test.thread;
      2 
      3 import org.testng.Assert;
      4 import org.testng.annotations.AfterClass;
      5 import org.testng.annotations.Test;
      6 import org.testng.internal.thread.ThreadUtil;
      7 
      8 import java.util.Collections;
      9 import java.util.HashSet;
     10 import java.util.Set;
     11 
     12 /**
     13  * Test for test level thread-count.
     14  *
     15  * @author <a href="mailto:the.mindstorm (at) gmail.com">Alex Popescu</a>
     16  */
     17 public class TestThreadCountTest {
     18   private Set<String> m_threads= Collections.synchronizedSet(new HashSet<String>());
     19 
     20   @Test
     21   public void test1() {
     22     m_threads.add(ThreadUtil.currentThreadInfo());
     23   }
     24 
     25   @Test
     26   public void test2() {
     27     m_threads.add(ThreadUtil.currentThreadInfo());
     28   }
     29 
     30   @Test
     31   public void test3() {
     32     m_threads.add(ThreadUtil.currentThreadInfo());
     33   }
     34 
     35   @AfterClass
     36   public void checkThreading() {
     37     Assert.assertEquals(m_threads.size(), 3, "Test should use 3 threads");
     38   }
     39 }
     40