//我试图通过使用testng
对它们进行分组来执行测试用例 package com.xyz.ngp.selenium;
import org.testng.annotations.*;
import javax.swing.*;
import com.thoughtworks.selenium.SeleneseTestNgHelper;
public class Grouping extends SeleneseTestNgHelper {
@BeforeGroups (groups = {"smoke"})
public void oneTimeSetUp() {
try {
String st="we are in BeforeGroups";
JOptionPane.showMessageDialog(null,st);
// scroll down to the bottom to see justprintsomething.
justprintsomething();
} catch (Exception e) {
e.printStackTrace();
}
}
@Test(groups = {"smoke"})
public void test1() throws Exception {
String st="you wanted to execute smoke group";
JOptionPane.showMessageDialog(null,st);
}
@Test(groups = {"functional"})
public void test2() throws Exception {
String st="you wanted to execute : either (functional) or this test: (test2)";
JOptionPane.showMessageDialog(null,st);
}
@Test(groups = {"test3"})
public void test3() throws Exception {
String st="you wanted to execute : this test: (test3)";
JOptionPane.showMessageDialog(null,st);
}
//@BeforeMethod (groups = "smoke") //do i need this beforegroups here?
public void justprintsomething() throws Exception {
try {
// it gets printed
String st="inside justprintsomething going to selenium.open";
JOptionPane.showMessageDialog(null,st);
// if i comment out the below line code works fine
selenium.open("http://www.google.com/");
} catch (Exception e) {
e.printStackTrace();
}
}
}
//我在selenium.open之前收到空指针异常错误。
答案 0 :(得分:0)
你从未初始化过selenium对象。