Junit测试:什么是失败? [英] Junit Test: what is Failure?

查看:308
本文介绍了Junit测试:什么是失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果junit测试的结果是失败,究竟是什么意思?
我假设在测试期间发生异常,但我找不到任何有关它的信息。
也是失败跟踪中的行是:

What exactly does it mean if the result of a junit test is "Failed" ? i assume that an exception happened during the test, but i can't find any information about it. also the line in the failure trace is:

Assert.assertTrue(result);

其中result只是一个布尔值。所以我不知道这一行的例外情况如何。

where result is just a boolean. so i dont know how an exception could happen in this line.

推荐答案

Assert.assertTrue(result);

Assert.assertTrue(result);

如果result为false,则此assert将失败,您将得到一个AssertionError。测试的作者想确保结果是真实的,如果它是错误的,那么有些事情是错误的,你应该检查上面的测试代码。

This assert will fail if result is false, and you will get an AssertionError. The writer of the test wants to make sure that the result is true, and if it is false then something is wrong and you should check the code under test above.

这篇关于Junit测试:什么是失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆