This is a little tutorial on how to use JUnit tesing ( JUnit 4.x ) in Eclipse. First you need to add the JUnit library to your project path and import it in order to use it. I'm also going to include an example in this post.
Why use JUnit test
The best reason for testing your code is that you can find your bugs and errors early and you don't have to burden your head later when you have already put it all together. It can save a lot of time in long-term. If you have a lot of code to cover and change it often, testing it is very recommended.
Concept
Running your test
Running as a JUnit test with eclpise
Running with code
Example
The Assert class API can be found
here.
Test class
Good example. Unit testing is sign of good developer. For those who are not very familiar with JUnit 4, here is a quick guide of JUnit 4 annotations.
ReplyDeleteAwesome tutorial! Thank you for the tips!
ReplyDeleteinteresting
ReplyDeleteTo find a whole list of test tools other than JUnit which is based on Java Platform and compare the tool functionality and how they match to testing needs can be found in Test Tools Suite
ReplyDelete