简体   繁体   English

我可以在Junit测试中运行PMD分析吗?

[英]Can I run PMD analysis in a Junit test?

I would like to create an automated junit test that passes if my code meets the requirements specified by PMD, and fails if it does not. 我想创建一个自动化的junit测试,如果我的代码满足PMD指定的要求,则通过,如果不满足,则失败。 Is this possible? 这可能吗?

It is possible tu run a PMD analysis in a JUnit test. 您可以在JUnit测试中运行PMD分析。 However, there exist PMD plugins for every Java IDE, build and CI tool out there. 但是,每个Java IDE,构建和CI工具都有PMD插件。 Are you sure they don't already do what you want to achieve? 您确定他们还没有做您想实现的目标吗?

If you still want to do it yourself, take a look at the class PMD. 如果您仍然想自己做,请查看PMD类。 It has the static method PMD.doPMD(configuration) which starts the analysis. 它具有启动分析的静态方法PMD.doPMD(configuration)

The same class also contains the main method in case you want to start it like from the command line. 如果您想从命令行启动它,则同一类还包含main方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以通过不同的参数将JUnit测试用例作为“多个测试”运行吗? - Can I run a JUnit test Case as “multiple tests” by different parameters? 如何使用 Junit 5 使用 Testcontainer 对 Kafka 运行集成测试 - How can I run Integration Test to Kafka with Testcontainer using Junit 5 无法在Windows中运行PMD - Can't run PMD in windows 在 Eclipse 中找不到作为 junit 测试运行 - can't find run as junit test in eclipse 无法运行TestNG或JUnit测试 - can't run TestNG or JUnit test 如何在JUnit测试类中运行(或更改)特定测试方法的顺序? - How can I run (or change the order of) specific test-methods in a JUnit test class? 如何通过右键单击eclipse上的包并选择“Run as JUnit test”,在包中及下面(递归地)运行所有junit测试 - How can I run all junit tests in a package and below (recursively) by right clicking the package on eclipse and selecting “Run as JUnit test” 为什么我不能在使用Maven的Junit测试运行中访问src / test / resources? - Why Can't I access src/test/resources in Junit test run with Maven? 我运行它时的JUnit测试错误 - JUnit test error when I run it CI/CD Junit 测试:我应该先构建 package 还是先运行测试? - CI/CD Junit tests: should I build the package first or I can run the test firsts?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM