package com.course.testng.thread; import org.testng.annotations.Test; public class ThreadOnXml { @Test() public void test1(){ System.out.println(); System.out.printf("test1的线程Thread Id: %s%n",Thread.currentThread().getId()); } @Test() public void test2(){ System.out.printf("test2的线程Thread Id: %s%n",Thread.currentThread().getId()); } @Test() public void test3(){ System.out.printf("test3的线程Thread Id: %s%n",Thread.currentThread().getId()); } }
<?xml version="1.0" encoding="utf-8" ?> <suite name = "thread" parallel="methods" thread-count="2" > <!-- methodes级别:所有用用例都可以在不同的线程下去执行 thread-count:代表最大并发线程数 xml文件配置这种方式不能指定线程池,只有方法上才可以指定线程池 <test name = "demo1"> <classes> <class name = "com.course.testng.thread.ThreadOnXml"/> </classes> </test> </suite>