TestNg Eclipse插件
由于用接口测试需要用到TestNg,所以去找了相关资料了解了下;
TestNg有很多优点,在网上都可以搜到;
执行TestNg有几种方式:命令行、Eclipse、ant等;
因为我用eclipse工具,所以就想办法在eclipse下执行TestNg了。
那么就必须要下载TestNg的eclipse插件了;
下载地址是: http://beust.com/eclipse.
对于不同版本的eclipse要用对应不同版本的TestNg,官网上是这样描述的:
- For Eclipse 3.4 and above, enter http://beust.com/eclipse.
- For Eclipse 3.3 and below, enter http://beust.com/eclipse1.
这两个链接是对应的是不同版本的TestNg eclipse插件;
下载下来以后,放在eclipse的plugins文件夹下,然后启动eclipse,Help-software update-Installed Software,查找到TestNg Eclipse插件,点击Install(安装),安装完成后,重启eclipse,然后去Windows-show view-other,java文件夹下,有TestNg,双击 图标, 在eclipse界面下面便会出现TestNg的窗体,此时新建一个class如:
package example1; import org.testng.annotations.*; public class SimpleTest { @BeforeClass public void setUp() { // code that will be invoked when this test is instantiated } @Test(groups = { "fast" }) public void aFastTest() { System.out.println("Fast test"); } @Test(groups = { "slow" }) public void aSlowTest() { System.out.println("Slow test"); } }
右键,run as,便可选择TestNg了,在Run Configrations中可配置,要运行的 class、method、suit等等;
浙公网安备 33010602011771号