我想在@Before方法中獲取當前正在執行的TestCase方法的名稱。 實施例在JUNIT @Before中獲取當前正在執行的@Test方法的名稱
public class SampleTest()
{
@Before
public void setUp()
{
//get name of method here
}
@Test
public void exampleTest()
{
//Some code here.
}
}
http://stackoverflow.com/questions/473401/get-name-of-curren tly-execution-test-in-junit-4? – ivarni
在您的測試類中添加一個字段'previousName',並在每個測試方法的末尾將其值設置爲After – TecHunter