1
我有以下的測試代碼:的IntelliJ的JUnit @RunWith沒有解決
package soundSystem;
import static org.junit.Assert.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = CDPlayerConfig.class)
public class SonyCDPlayerTest {
@Autowired
private ICompactDisk cd;
@Test
public void cdShouldNotBeNull() {
assertNotNull(cd);
}
}
這是一個Maven項目,問題是完全相同的代碼將在Eclipse中運行,而不是在的IntelliJ。
我無法找到一個方法來解決@RunWith
真的真的ty,我一直在整個下午都在打架,之前我不知道應該在項目結構中添加jar,但是我仍然不明白爲什麼我必須手動添加它我的maven pom有junit和項目結構有maven:junit –
那部分我不能告訴你;-( – GhostCat
ty都是一樣的,:-) –