[英]NoClassDefFoundError when using @RunWith(PowerMockRunner.class)
[英]@Before is not getting executed when @RunWith(DataProvider.class)
我有一個測試用例類。 但是@Before沒有被調用。 如何首先調用@Beofre並調用@RunWith?
@RunWith(DataProviderRunner.class)
public class Ab extends xyz {
@DataProvider
public static Object[][] workBookSheet()
{
Object[][] tableArray = ex.getTableArray("Ab");
return (tableArray);
}
@Test
@UseDataProvider("workBookSheet")
public void Abc(String TestName, String sDescription)
{
}
xyz類具有以下代碼以及@Before注釋。
protected static ExcelSheet ex;
static {
try {
String Path = getPath();
ex = new ExcelSheet("sheet.xlsx");
} catch (IOException e) {
e.printStackTrace();
}
}
@Before
{
public static String getPath()
{
}
}
還是Junit中有一種方法可以將DataProvider與RunWith一起使用並先調用@Before。 還是有一種創建自定義注釋並使用@RunWith添加它們的方法?
靜態方法不參與多態
@Before
public String getPath() {
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.