aisam

1.pom.xml配置下载需要的jar。

    <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
          <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>3.2.3.RELEASE</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>3.2.3.RELEASE</version>
        </dependency>

2.然后在所需要测试的类上加上以下内容:

@RunWith(SpringJUnit4ClassRunner.class)  
@ContextConfiguration(locations = "classpath*:spring.xml") //spring.xml是tomcat加载配置文件的入口

public class MyTest {
   
    @Test
    public void testSearch() {
  
    }

}

 

分类:

技术点:

相关文章:

  • 2021-05-07
  • 2021-08-16
  • 2022-02-11
  • 2021-06-03
  • 2021-09-30
  • 2021-12-28
  • 2021-06-25
猜你喜欢
  • 2022-01-04
  • 2021-11-18
  • 2021-12-08
  • 2022-12-23
  • 2021-12-28
  • 2022-01-09
相关资源
相似解决方案