Java – JUnit test: meaning of failure (“not yet implemented”);?

What is the meaning of this code?

for example

@Test
    public void testGetDiameter() {
        **fail("Not yet implemented");**
    }

Solution

Using the eclipse IDE, if you will generate JUnit testcase stubs, it will add failed test methods ("not yet implemented") Therefore, if you forget to add the actual implementation, the test case will fail and the error or assertion error will be displayed as "not implemented yet"

Therefore, the eclipse stub generator provides you with the default implementation of the test case, which will always fail, and it is the responsibility of the unit test case developer to replace it with some meaningful test statements You can think of it as todo: for you

If you delete this statement, your test will pass, but it does not actually do any type of test for you, but it will only increase the count of your test cases

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>