南京seo建站,做外链等于网站更新么,怎么添加字体在wordpress,网站ftp根目录junit junit关于JUnit 5迁移的好处之一是#xff0c;您可以在老式模式下运行JUnit 4测试#xff0c;并且所有内容仍然兼容。 不利的一面是#xff0c;某些注释和方法在JUnit 4和JUnit 5中具有相同的名称#xff0c;并且当两组库依赖项都可用时#xff0c;很容易导入错误的… junit junit 关于JUnit 5迁移的好处之一是您可以在老式模式下运行JUnit 4测试并且所有内容仍然兼容。 不利的一面是某些注释和方法在JUnit 4和JUnit 5中具有相同的名称并且当两组库依赖项都可用时很容易导入错误的内容并生成不符合要求的测试。努力工作。 然而更糟糕的是当没有意义的测试也没有通过构建时。 考虑以下测试 import org.junit.Test; import org.junit.jupiter.api.BeforeEach; import static org.junit.Assert.assertEquals; public class AccidentalJUnit4Test { BeforeEach public void beforeEach() { } Test public void test() { assertEquals( 1 , 1 ); } } 这是JUnit 5的注释和JUnit 4的可怕的汤。 它在IDE中运行但是在maven构建中它被忽略因为Test来自错误的JUnit并且我没有运行junit-vintage 。 那么运行junit-vintage吗 这是怎么发生的 就我而言我已经导入了JUnit 5的TestContainers集成该集成具有对JUnit 4的传递依赖。这不是很好但这还不是末日。 但是我只想在代码中使用JUnit 5测试但是我可能会意外地用JUnit 4位编写测试没有人会注意到 这些一半形式的测试从未打算如此因此我希望它们使构建失败。 什么不起作用 Checkstyle – checkstyle可以扫描禁止的import语句但是我不使用它进行src/test扫描并且我们项目的checkstyle规则与另一个使用junit-vintage的有效项目共享。 Macker –复杂的扫描仪似乎没有开箱即用的答案 Enforcer –这将阻止我包括JUnit 4依赖项…除了我忍不住允许 我为什么要在乎 通过添加自动化功能来发现已知错误并告诉您有关错误的信息这比在周围发出警告要好得多而且仍然可能出现错误从而使事情防错。 就像有人张贴标语来警告该水非常热而不是在合适的温度下提供水一样 任何可以赋予我们强制功能的东西都是有好处的。 什么有效 我在GitHub上找到了一个愚蠢而简单的答案。 这个Maven Grep插件效果很好 build plugins !-- grep maven plugin set to filter naughty JUnit4 stuff -- plugin groupId net.radai/ groupId artifactId grep-maven-plugin/ artifactId version 1.1/ version executions execution goals goal grep/ goal / goals phase test/ phase configuration greps grep failIfFound true/ failIfFound filePattern src/test/java/**/*.java/ filePattern grepPattern import\s(static\s)?org\.junit\.(Assert|Test|Before|After|AfterClass|Assume|BeforeClass|ClassRule|Rule|FixMethodOrder|Ignore|Rule)/ grepPattern outputPattern Found JUnit 4 imports in file ${fileName} at line ${lineNumber} : ${line}/ outputPattern / grep / greps / configuration / execution / executions / plugin / plugins / build !-- you also need to add the distribution repo -- pluginRepositories pluginRepository id ossrh/ id url https://oss.sonatype.org/content/groups/public / url / pluginRepository / pluginRepositories 上面的内容对我有用可以防止发生错误它可能对您有用。 我在GitHub中放置了上述代码的一个工作示例由于正确的原因而失败。 信用到期 我几乎放弃了上述问题。 幸运的是开源社区非常出色。 Radai Rosenblatt于2016年编写了此插件。一个名为Michal Lozinski的撰稿人于2017年添加了文件模式扫描。 当我们初次尝试使用上述配置时它不起作用。 文档没有描述如何执行此操作但是阅读插件的代码显示可以使用filePattern 。 但是它没有用。 我今天联系了Radai他更新了该插件的发行版现在可以使用了。 没有开源这将是不可能的。 没有作者承担对陌生人的帮助的责任这是不可能的。 谢谢 翻译自: https://www.javacodegeeks.com/2019/08/crossing-junit-streams.htmljunit junit