Running on Java 19-ea+23-1706 (Preview)
Home of The JavaSpecialists' Newsletter

2.19 Extending the Tests

Juppies 2 by Dr Heinz M. Kabutz

When we find a bug in our code, a good idea is to write a unit test to demonstrate the bug. It has happened many times that a bug disappeared, and then suddenly came back again as a programmer changed the code and re-introduced it. In our test code we store the String beforeShuffle and afterShuffle and then confirm that the final shuffle is not one of those two.

Adding a message into the assertNotEquals() method makes it easier for us to figure out what went wrong in our test.

When writing software, the better our tests, the more productive we will be. Good tests show the difference between professional and amateur programmers. I hope to instil good coding practices that you can use to become a pro. Even the best programmers make mistakes. These tests help us discover our mistakes early.

Test, test, test, test, test.

Before writing new functionality, we spend time thinking of how we can test it.


When you load these comments, you'll be connected to Disqus. Privacy Statement.

Table of Contents

We hope you enjoyed this tutorial. If you did, you will also enjoy our courses. We suggest you start with Extreme Java - Advanced Java, followed by Extreme Java - Concurrency Performance for Java 8.

About the Author

Heinz Kabutz Java Conference Speaker

Java Champion, author of the Javaspecialists Newsletter, conference speaking regular... About Heinz

Superpack '22

Superpack '22 Our entire Java Specialists Training in one huge bundle more...

Free Java Book

Dynamic Proxies in Java Book
Java Training

We deliver relevant courses, by top Java developers to produce more resourceful and efficient programmers within their organisations.

Java Consulting

We can help make your Java application run faster and trouble-shoot concurrency and performance bugs...

Java Emergency?

If your system is down, we will review it for 15 minutes and give you our findings for just 1 € without any obligation.