# Spring与Junit的整合

# Spring与Junit的整合

今天学习了下,总结一下,使用方法

## 导入依赖

```
 <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>5.0.2.RELEASE</version>
 </dependency>
 <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
 </dependency>
```


## 使用

```
@ContextConfiguration(locations = "classpath:bean.xml")
@RunWith(SpringJUnit4ClassRunner.class)
public class Mytext {
    @Autowired
    private IAccountService ac;
    @Test
    public void Mytest1(){
        ac.transfer("bbb","ccc",500f);
    }
}
```

发布了2 篇原创文章 · 获赞 0 · 访问量 24

猜你喜欢

转载自blog.csdn.net/u012557221/article/details/104344675