01: package test.thread;
02:
03: import org.testng.Assert;
04: import org.testng.annotations.Test;
05: import org.testng.annotations.AfterClass;
06: import org.testng.internal.thread.ThreadUtil;
07:
08: import java.util.Collections;
09: 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@gmail.com">Alex Popescu</a>
16: */
17: public class TestThreadCountTest {
18: private Set<String> m_threads = Collections
19: .synchronizedSet(new HashSet<String>());
20:
21: @Test
22: public void test1() {
23: m_threads.add(ThreadUtil.currentThreadInfo());
24: }
25:
26: @Test
27: public void test2() {
28: m_threads.add(ThreadUtil.currentThreadInfo());
29: }
30:
31: @Test
32: public void test3() {
33: m_threads.add(ThreadUtil.currentThreadInfo());
34: }
35:
36: @AfterClass
37: public void checkThreading() {
38: Assert.assertEquals(m_threads.size(), 3,
39: "Test should use 3 threads");
40: }
41: }
|