简体   繁体   English

删除junit测试以构建ant

[英]removing junit testing to build in ant

Not so much a programming question but I figured I'd ask anyway. 不是一个编程问题,但我想我还是会问。

How do I make it so ant doesn't require that all the junit tests pass before building? 我怎么做到这样蚂蚁不需要在建造之前通过所有的junit测试? In netbeans I can build the project without it testing first. 在netbeans中,我可以在没有先测试的情况下构建项目。 However, when I run ant, it makes sure all my junit tests pass first. 但是,当我运行ant时,它确保我的所有junit测试都先通过。 I am running ant from the command line in my netbeans project directory. 我在netbeans项目目录中从命令行运行ant。 Which files do I need to modify to tell ant not to do that? 我需要修改哪些文件告诉蚂蚁不要这样做?

To add some detail, it looks like the ant script goes into the build.xml and build-impl.xml files to determine what to do. 要添加一些细节,看起来ant脚本会进入build.xml和build-impl.xml文件以确定要执行的操作。 build-impl.xml says not to edit it and to edit build.xml instead. build-impl.xml表示不编辑它并编辑build.xml。 Build.xml doesn't have any options for junit testing though, so I'm wondering where to disable testing. Build.xml没有任何junit测试选项,所以我想知道在哪里禁用测试。

Please let me know. 请告诉我。

Thanks, jbu 谢谢,jbu

One of your Ant XML files should have a "junit" task in it; 你的一个Ant XML文件应该有一个“junit”任务; in your case, it sounds as if this task has the "haltonerror" attribute set to "on", which causes the build to halt if any of the JUnit tests fail. 在您的情况下,听起来好像这个任务将“haltonerror”属性设置为“on”,这会导致构建在任何JUnit测试失败时停止。 If you can't spot the junit directive immediately, it might be in an included file (look for "import" directives, usually near the top of the file). 如果你不能立即发现junit指令,它可能在一个包含的文件中(查找“import”指令,通常在文件的顶部附近)。

You can set this attribute to "off" to change this behaviour, but I'd strongly advise against it; 您可以将此属性设置为“off”以更改此行为,但我强烈建议不要这样做; you want your unit tests to tell you when the code is broken. 您希望您的单元测试告诉您代码何时被破坏。 If any of the tests are going to be known failures due to changes in the code, it's better to fix the test before continuing with your code changes than to turn it off. 如果由于代码更改而导致任何测试失败,则最好在继续进行代码更改之前修复测试,而不是将其关闭。

Depending on the exact project type, just run a target that does not include testing. 根据确切的项目类型,只需运行不包含测试的目标。 For basic Java SE projects: 对于基本的Java SE项目:

ant jar

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM