我有一个小型的java项目,我使用TestNG + Eclipse执行,并且运行良好。 使用属性我已经外化的测试数据文件,我在我的测试类的一个静态块初始化 -属性文件的静态初始化失败,并生成ant
public class SanityTest extends SelTestCase {
static Properties properties = new Properties();
static String pickUp;
static String dropOff;
static {
try {
properties
.load(SanityTest.class
.getResourceAsStream("/com/product/testdata/testdata.properties"));
pickUp = properties.getProperty("pickUp");
dropOff = properties.getProperty("dropOff");
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Verifies the booking of car on car hire market
* @throws Exception
*/
@Test
public void testBookingModule() throws Exception {
// Some tests here
}
但是,当我使用Ant构建(1.8)我碰到下面的目标异常“运行”执行相同的 -
[testng] Caused by: java.lang.NullPointerException
[testng] at java.util.Properties$LineReader.readLine(Properties.java:418)
[testng] at java.util.Properties.load0(Properties.java:337)
[testng] at java.util.Properties.load(Properties.java:325)
我找不出多少,并检查“bin”是否已创建并具有所有相应的文件。 有没有我错过的东西?
你是如何格式化你的prop文件的内容的? – karla