如何准备testng.xml多次从多个包中调用多个方法(每次不同)

时间:2016-01-05 18:31:23

标签: java web-services selenium-webdriver testng

我的.jmx文件看起来像[test-jmx文件],我们为唯一名称创建了不同的包,并创建了testng.xml文件,如下所示。

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="234Login" verbose="1">

	<test name="Login">
		<classes>
			<class name="com.CompanyName.api.test.CompanyNameTestConfig" />
			<class name="com.CompanyName.api.test.auth.LoginTest">
				<methods>
					<include name="check_active" />
					<include name="post_login" />
				</methods>
			</class>
		</classes>
	</test>
	<test name="Default_1">
		<classes>
			<class name="com.CompanyName.api.test.defaultaccess.DefaultAccessTest">
				<methods>
					<include name="get_methods" />
					<include name="get_accountConfiguration" />
					<include name="get_userRelatedLocations" />
				</methods>
			</class>
		</classes>
	</test>
	<test name="Services">
		<classes>			
			<class name="com.CompanyName.api.test.services.UserServicesTest">
				<methods>
					<include name="user" />
				</methods>
			</class>
		</classes>
	</test>
	<test name="Default_2">
		<classes>			
			<class name="com.CompanyName.api.test.defaultaccess.DefaultAccessTest">
				<methods>
					<include name="get_ToDoTaskWithPaging" />
				</methods>
			</class>
		</classes>
	</test>
	<test name="MedicalApptRead_1">
		<classes>			
			<class name="com.CompanyName.api.test.medicalappt.MedicalApptTest">
				<methods>
					<include name="get_AllScheduleType" />
					<include name="get_AllScheduleStatus" />
				</methods>
			</class>
		</classes>
	</test>
	<test name="Default_3">
		<classes>			
			<class name="com.CompanyName.api.test.defaultaccess.DefaultAccessTest">
				<methods>
					<include name="get_WardsOfLocation" />
					<include name="get_RoomForLocation" />
				</methods>
			</class>
		</classes>
	</test>
	<test name="MedicalApptRead_2">
		<classes>			
			<class name="com.CompanyName.api.test.medicalappt.MedicalApptTest">
				<methods>
					<include name="get_DayScheduleFromViewForDoctors" />
					<include name="get_WaitListWithPagingForDoctor" />
				</methods>
			</class>
		</classes>
	</test>
	<test name="PlanRead">
		<classes>			
			<class name="com.CompanyName.api.test.planread.Planread1">
				<methods>
					<include name="get_DoctorInOutStatus" />
				</methods>
			</class>
		</classes>
	</test>
<test name="Logout">
		<classes>			
			<class name="com.CompanyName.api.test.auth.LogoutTest">
				<methods>
					<include name="post_logout" />
				</methods>
			</class>
		</classes>
	</test>

</suite>

JMXFile 当我通过传递像username和amp;等参数从主测试套件运行上述测试套件时密码,前两个方法(check_active,post_login)只运行。在Remaining类中,所有未指定为包含标记的测试方法也在运行。如何以相同的顺序运行上述.xml文件中包含的所有测试方法。我没有指定测试方法的任何优先权。我需要创建多个测试套件,并需要创建主测试套件以按顺序运行所有测试套件。请帮帮我。提前谢谢。

1 个答案:

答案 0 :(得分:0)

也许您应该尝试将preserve-order="true"添加到testng.xml文件中的所有<test>标记