From the course: Practical Test-Driven Development for Java Programmers

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

JUnit basics

JUnit basics

- [Instructor] Now I'm not sure if you've used JUnit before, so in case you haven't I'm just going to point out a couple of things. First of all just above the method here we've got an annotation of @test. This annotation unsurprisingly means that the method that follows is a test method. But it means that when we tell eclipse we want to run all of our tests, this method will be run. It's the annotation that tells eclipse this method is a test method. So it's important we have the annotation there. If we right click on our workspace here and choose run as and then JUnit test, well we'll see that down here this test here is the name of the method. So because we have the @test annotation this method was run. And we've got up here a red bar. If you remember our workflow is red green refactor and this is the red part. That means that one or more tests failed. Just above the red bar we can see that we had one out of one test ran, no tests gave errors, but one test gave a failure. An error…

Contents