繁体   English   中英

在蚂蚁中启用断言

[英]enabling assertions in ant

我想在ant启用断言功能。 在我的ant build.xml ,我将下面的内容尝试启用断言。

<project> ... <assertions> <enable/> </assertions> </project>

我把断言放在一个junit文件中,该文件只包含一个函数,

testAssertions() {
  assert false;
}

运行ant ,不会抛出断言失败..如何在此设置中启用断言?

看起来你的<assertions>子元素是<project>子元素,这是正确的吗?

我假设您正在通过<junit> ant任务运行测试。 如果这是正确的,那么<assertions><enable/></assertions>子元素应该是<junit>子元素。

为了启用断言,我编辑了nbproject/project.properties并进行了更改

# Space-separated list of JVM arguments used when running the project.
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
# To set system properties for unit tests define test-sys-prop.name=value:
run.jvmargs=

run.jvmargs=\
    -ea

执行此操作后,在执行ant run时启用了断言。

暂无
暂无

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

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