我正在使用带有testng插件(版本6.14.0.201802161500)的eclipse 2018-09(4.9.0)。我创建了一个maven项目,以从教程中学习testng。我想在Eclipse中运行testng工厂方法,但运行菜单中没有“ testng”选项。如何使其在工厂运行?
我的代码:
package com.learn.classes;
import org.testng.annotations.Test;
//run with testng is present for this.
public class SimpleTest {
@Test
public void simpleTest() {
System.out.println("Simple test Method");
}
}
package com.learn.factory;
import org.testng.annotations.Factory;
import com.learn.classes.SimpleTest;
//run with testng is NOT present for this.
public class SimpleTestFactory {
@Factory
public Object[] factoryMethod() {
return new Object [] {new SimpleTest(), new SimpleTest()};
}
}
解决方案: 为上述类或方法创建一个xml套件,并使用testng运行它。
前任。myfactory.xml
<suite name="Factorty Methods" verbose="1">
<test name="My factory method">
<classes>
<class name="factory.SimpleTestFactory" />
<methods>
<include name="factoryMethod" />
</methods>
</classes>
</test>
</suite>
拉丁的传说
相关分类