【发布时间】:2017-07-13 14:19:56
【问题描述】:
在我的应用程序中
`CategoryDao` is a `interface`, `Category` is a model `class`
我的代码是
CategoryTestCase.java
package com.binod.onlineshopping.category.test;
import com.binod.onlineshopping.category.dao.CategoryDao;
import com.binod.onlineshopping.category.model.Category;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.testng.AssertJUnit.assertEquals;
/**
* Created by binod on 7/13/17.
*/
public class CategoryTestCase {
private static AnnotationConfigApplicationContext context;
private static CategoryDao categoryDao;
private Category category;
@BeforeClass
public static void init() {
context = new AnnotationConfigApplicationContext();
context.refresh();
categoryDao = (CategoryDao) context.getBean("categoryDao");
}
@Test
public void addCategory(){
category=new Category();
category.setCname("Television");
category.setCdescription("TV is the product");
category.setImageUrl("c_Tv.png");
assertEquals("sucessfully inserted..",true,categoryDao.addCategory(category));
}
}
错误是:
Error:(34, 6) java: reference to assertEquals is ambiguous
both method assertEquals(java.lang.String,boolean,boolean) in org.testng.AssertJUnit and method assertEquals(java.lang.String,java.lang.Object,java.lang.Object) in org.testng.AssertJUnit match
我试图在我的springmvc 和hibernate 项目中进行junit 测试。我试图在我的insert 模块中进行测试。但它给出了上述错误。
我看到了许多教程和参考资料,但我无法处理该错误。
提前致谢。
【问题讨论】:
-
我想
categoryDao.addCategory有Boolean类型。我说的对吗? -
或...
assertTrue("successfully inserted", categoryDao.addCategory(category))
标签: java spring spring-mvc junit