Skip to Content
100 Java Mistakes and How to Avoid Them
book

100 Java Mistakes and How to Avoid Them

by Tagir Valeev
May 2024
Intermediate to advanced content levelIntermediate to advanced
352 pages
10h 45m
English
Manning Publications
Content preview from 100 Java Mistakes and How to Avoid Them

10 Unit testing

This chapter covers

  • Mistakes associated with assert statements
  • Misuse of assertion methods
  • Problems that happen when testing whether an exception is thrown
  • How a test case may succeed even if an assertion fails
  • Writing an incorrect test method that is not even executed

While unit testing is aimed at reducing the number of bugs in a program, the unit test itself is a program, so it’s natural that it may contain bugs, too. Some developers assume it’s not a big problem because if a unit test has a bug, then it will likely fail. However, I have seen many buggy unit tests that actually don’t test anything, so if the bug appears in the program, then the test won’t do its job of detecting the regression. In this chapter, we explore ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

The Complete Coding Interview Guide in Java

The Complete Coding Interview Guide in Java

Anghel Leonard
Java Coding Problems

Java Coding Problems

Anghel Leonard
Modern Java in Action

Modern Java in Action

Raoul-Gabriel Urma, Mario Fusco, Alan Mycroft

Publisher Resources

ISBN: 9781633437968Supplemental ContentPublisher SupportOtherPublisher WebsiteSupplemental ContentErrata PagePurchase Link