我正在研究硒自动化。 我的团队使用xml文件来测试数据。 xml文件中的测试数据将作为bean和属性。
每个bean都是一个测试用例的数据。
现在,我们正在为每个bean创建每个@Test方法,如下所示:
ApplicationContext ctx = new ClassPathXmlApplicationContext("/PostPaidRegistration.xml");
RegistrationBean user = (RegistrationBean)ctx.getBean("postpaidTC1");
现在在测试用例中我们将使用“postpaidTC1”bean的数据。
对于另一个测试用例,我们将另一个@Test方法编写为
ApplicationContext ctx = new ClassPathXmlApplicationContext("/PostPaidRegistration.xml");
RegistrationBean user = (RegistrationBean)ctx.getBean("postpaidTC2");
我想知道,不是在xml中为bean创建许多@Test方法,而是通过获取BeanID以单个@Test方法作为循环来运行xml中的所有bean(测试数据)。
我的Xml如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/data/mongo
http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
http://www.springframework.org/schema/data/repository
http://www.springframework.org/schema/data/repository/spring-repository-1.0.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa-1.0.xsd">
<bean id="postpaidTC1" class="com.tecnotree.CLM.beans.RegistrationBean">
<property name="service" value="GSM SERVICE" />
<property name="subService" value="Voice"/>
<property name="technology" value="gsm"/>
<property name="plan" value="POSTPAID ADV REN"/>
<property name="mCategory" value="POSTPAID NORMAL 2"/>
<property name="mSelection" value="Automatic"/>
<property name="firstName" value="Sarada"/>
<property name="middleName" value="M" />
<property name="lastName" value="Akurathi"/>
<property name ="dob" value="19/02/1989"/>
<property name ="prefLang" value="ENGLISH"/>
<property name ="prefMedium" value="Email"/>
<property name ="prefMediumValue" value="samyak@tt.com"/>
<property name ="streetName" value="Gandhi Nagar"/>
<property name ="buildingNumber" value="12"/>
<property name ="docPurpose" value="Proof Identity"/>
<property name ="docType" value="PANCARD"/>
<property name ="docId" value="VETY3D343"/>
<property name ="docPlaceOfIssue" value="Chennai"/>
<property name ="billCycle" value="5th TO 4th MONTHLY BILL CYCLE"/>
</bean>
<bean id="postpaidTC2" class="com.tecnotree.CLM.beans.RegistrationBean">
<property name="firstName" value="Suneetha"/>
<property name="lastName" value="ss"/>
<property name ="dob" value="19/02/1989"/>
<property name ="prefLang" value="ENGLISH"/>
<property name ="prefMedium" value="Email"/>
<property name ="prefMediumValue" value="samyak@tt.com"/>
<property name="plan" value="POSTPAID ADV REN"/>
</bean>
</beans>
答案 0 :(得分:1)
可能你可以做
Map<String, RegistrationBean> beanMap = ctx.getBeansOfType(RegistrationBean.class)
然后遍历beanMap