我有一个接口(Clause.java)和两个实现类(OrderClause.java和GroupClause.java) 我无法创建Clause.java类的实例 请参阅我的ClauseTest类示例:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath*:config/applicationContextList.xml")
public class ClauseTest {
public ClauseTest() {
}
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of getQueryString method, of class Clause.
*/
@Test
public void testGetQueryString() {
System.out.println("getQueryString");
Clause instance = new ClauseImpl();
String expResult = "";
String result = instance.getQueryString();
assertEquals(expResult, result);
fail("The test case is a prototype.");
}
答案 0 :(得分:1)
你写的是Clause
是一个接口,而不是类。您无法直接实例化界面。您需要创建实现该接口的类的实例:
Clause instance = new OrderClause();