利用IfProfileValue注解标集成测试用例

Spring提供了一个IfProfileValue的注解,可以在不使用maven插件的情况下,区分集成测试与单元测试用例。

代码如下:

1
2
3
4
5
6
7
8
import org.springframework.test.annotation.IfProfileValue;

@IfProfileValue(name="test-groups", value="integration")
public class ExampleIntegrationTest{
@Test
public void longRunningServiceTest() throws Exception {
}
}

如果只想运行单元测试,则执行:

1
mvn clean test

如果要执行集成测试与单元测试,则执行:

1
mvn clean test -Dtest-groups=integration

利用IfProfileValue注解标集成测试用例

https://www.ovasty.com/posts/ifprofilevalue.html

作者

ovasty

发布于

2021-03-01

更新于

2021-03-01

许可协议

评论

You forgot to set the shortname for Disqus. Please set it in _config.yml.