When you are unit testing, it is sometimes necessary to supplement an object with dummy data. Unfortunately, to fill a large object manually, it crawls a lot of time and work. Fortunately, there is a tool that saves us the time and work!
When you want to build, install, clean… maven. You have to run all the unit tests. The problem is when you have plenty of tests or database connections to test, the time that the build need is way too long. It is possible to build without running the tests. You can configure that in Eclipse:
You can test a private constructor by using Reflection. Insert the following code in your unit test class:
How can you find the similarity rate of two objects expressed by a percentage? Read it below.
For example, I have two objects with the same object type. In this example we have an object ‘contact’.
What if you have an object without ID. How do you know if that object already exists in the database?
Most people want uniformity in their database. That is not always easy when you let the user enter data. Website URLs can come in all sizes. But how should you create an exactly uniform URL?
When you test a DAO class. It is possible you insert or update test data in your database. Of course, we don’t want that. There is a possibility to rollback the transaction when your test is completed.
We use EasyMock to do so.
It is possible to test getters and setters (properties) from your model class. Through a test class, it is done in no time.
The equals and hashcode methodes are simple to test with JQNO.
To test your web service, you can use Smock. Smock compares your request with the response by XML files. You just need a response.xml file with your response and a request.xml file with your request.