加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

java – 使用@category spring和gradle运行jUnit测试

发布时间:2020-12-15 01:46:11 所属栏目:大数据 来源:网络整理
导读:我需要运行一些集成测试和一些单元测试,我使用的是spring,gradle和jUnit 4. 我使用了jUnit类@Category(UnitTestCategory.class)和@Category(IntegrationTestCategory.class)并添加了i test { useJUnit { includeCategories 'org.gradle.junit.CategoryA' exc

我需要运行一些集成测试和一些单元测试,我使用的是spring,gradle和jUnit 4.

我使用了jUnit类@Category(UnitTestCategory.class)和@Category(IntegrationTestCategory.class)并添加了i

test {
    useJUnit {
    includeCategories 'org.gradle.junit.CategoryA'
    excludeCategories 'org.gradle.junit.CategoryB'
    }
}

用于gradle以包含/排除类别.我的想法是,我不想混合单元测试和集成测试,我有一个类别.

问题是我必须使用spring和categories,而@RunWith(…)只能接收一个类param. – RunWith(SpringJUnit4ClassRunner.class)或@RunWith(Categories.class).

我无法使用@RunWith({Categories.class,SpringJUnit4ClassRunner.class}),我必须运行spring和categories.再加上未来我可能还需要添加其他类,不仅仅是spring和category.所以我需要@RunWith(…)的多个参数

https://docs.gradle.org/current/userguide/java_plugin.html

有人有解决方案吗?

最佳答案
您可以使用spring junit rules而不是春季跑步者.然后作为跑步者,您可以使用类别

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读