Spring*Junit

1.添加依赖

sping-test和junit的相关依赖(另还有必须的spring依赖)

      <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-testartifactId>
            <version>4.1.3.RELEASEversion>
        dependency>
        <dependency>
            <groupId>junitgroupId>
            <artifactId>junitartifactId>
            <version>4.12version>
        dependency>

写例子

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath*:mvc-dispatcher-servlet.xml")
public class RemoteAITest {
    @Resource
    AiService service;

    /**
     * c测试获取问题答案
     */
    @Test
    public void getAnswerFormAI(){
        System.out.print("你好");
    }

    /**
     * 测试点评
     */
    @Test
    public void addlike2AI(){
//        service.isLike("1","1");
    }
}

你可能感兴趣的:(Spring,spring,junit)