Java Software Testing tutorials: unit testing, open source, JUnit, Mockito, TestNG, Spring, JGiven, etc.
In this article, Brett Schuchert discusses how modern mocking tools affects positively our ability to work with legacy code and the possible negative implications of using mocking tools. These tools allow us to perform unit testing without actually changing the underlying code. He starts with a discussion about the challenges of unit testing and how mocking tools help to solve them; at least on the surface.
This blog post by Stuart Gunter shares some best practices to perform unit testing on Spring MVC views. The concept follows a BDD style to write unit tests that leverages the MVC pattern in much the same way as the real application, but exploits the power of standard unit testing practices like mocking, assertions and verification. This is achieved with the open source software testing tool TestNG and using the infrastructure provided by Spring through its integration testing features in order to execute the unit test. The post shows the code, also available on GitHub, used to do this. It also explains the design decisions that supports this approach.
Practical Unit Testing with TestNG and Mockito is a book that is intended especially for those who would like to start unit testing their code, but are unsure about how to get started and what to focus on. It presents the unit testing domain with examples in the Java language using the TestNG and Mockito open source tools.
Mockito is an open source mock framework for Java that letsyou write beautiful tests with clean and simple API. This video shows how to verify mock objects using Mockito.
The open source JUnit unit testing tool has been a blessing for Java developers. However, many programmers think that it is enough to learn the JUnit API and write a few tests in order to have a well-tested application. This idea is more dangerous than not doing unit tests because it leads to a wrong sense of code quality. Learning JUnit is the easiest part of unit testing your Java code, but writing good tests is the hard part.
Issues with testability in Java boil down to our inability to write tests or the excess trouble we have to go through to get it done. In this article, based on chapter 7 of the book “Effective Unit Testing – A guide for Java developers”, Lasse Koskela shares a set of dos and don’ts for testable design. In the tips provided, he recommends to avoid complex private methods, static methods, logic in constructors and to favor composition over inheritance.
Cucumber-JVM is a pure Java implementation of Cucumber, a software testing tool that support Behavior Driven Development with plain text specifications and unobtrusive automation in Ruby. Cucumber-JVM supports Clojure, Groovy, Java, JavaScript (Rhino interpreter), Python (Jython interpreter), Ruby (JRuby interpreter) and Scala. It is now written in a native Java-API, which compiles down to fast JVM bytecode. It enables many JVM capabilities and makes it even easier to integrate with your Java applications. Note from the Editor: we had the regret to realize after publication that there is no sound on this video. We should have tested this before ;o(