我想在弹簧单元测试(SpringJUnit4ClassRunner)的拆卸方法中使用bean。但是这个方法(用@AfterClass 注释)应该是静态的。有什么解决办法?
例子:
@RunWith(SpringJUnit4ClassRunner.class)
//.. bla bla other annotations
public class Test{
@Autowired
private SomeClass some;
@AfterClass
public void tearDown(){
//i want to use "some" bean here,
//but @AfterClass requires that the function will be static
some.doSomething();
}
@Test
public void test(){
//test something
}
}