IDEA下Maven单元测试

IDEA下Maven单元测试_第1张图片

 

/**
 * 让测试运行于Spring测试环境
 */
@RunWith(SpringJUnit4ClassRunner.class)
/** 注入相关的配置文件:可以写入多个配置文件 **/
@ContextConfiguration(locations = {"classpath:spring.xml","classpath:spring-mybatis.xml"})
public class CarIncomeInvoiceControllerTest {

    @Autowired
    CarIncomeInvoiceService carIncomeInvoiceService;

    @Before
    public void setUp() throws Exception {
    }
    @Test
    public void get() {
        Object object=carIncomeInvoiceService.get(2);
        System.out.println(object.toString());

    }
    @After
    public void tearDown() throws Exception {
    }

 对于ContextConfiguration的classpath可以根据编译后的target文件编写 

classpath:只会到你的class路径中查找找文件;

IDEA下Maven单元测试_第2张图片

你可能感兴趣的:(JAVA)