Posted In: Hamcrest, Junit, Testing

How to unit test a date – JUnit + Hamcrest

Usecase – You need to unit test Date output and write multiple scenarios to test the data. Hamcrest library may be useful to achieve that Hamcrest Date Matchers Hamcrest 1.3 Classes used from Hamcrest import org.hamcrest.number.OrderingComparison; Using ErrorCollector so that execution continues even if assert statement fails. Output

Read More

Tags: ,

by , on August 13th, 2017

Posted In: Hamcrest, Junit, Testing

How to unit test a Integer array – JUnit + Hamcrest

Usecase – You need to unit test Integer array output and write multiple scenarios to test the data. Hamcrest library may be useful to achieve that Hamcrest 1.3 Classes used from Hamcrest org.hamcrest.collection.IsArray; org.hamcrest.collection.IsArrayContaining; org.junit.rules.ErrorCollector; Using ErrorCollector so that execution continues even if assert statement fails. Output

Read More

Tags:

by , on August 12th, 2017

Posted In: Hamcrest, Junit, Testing

How to unit test a string array – JUnit + Hamcrest

Usecase – You need to unit test string array output and write multiple scenarios to test the data. Hamcrest library may be useful to achieve that Hamcrest 1.3 Classes used from Hamcrest org.hamcrest.collection.IsArray; org.hamcrest.collection.IsArrayContaining; org.junit.rules.ErrorCollector; Using ErrorCollector so that execution continues even if assert statement fails. Output

Read More

Tags:

by , on August 12th, 2017

Posted In: JSON

Check two JSON Objects for equality – Hamcrest-JSON

  This example uses hamcrest-json library     Examples using Hamcrest-JSON   1. Success test with a org.json.JSONObject   2. Error test with a org.json.JSONObject   3. Success test with a JSON String   4. Error test with a JSON String  

Read More

Tags: , , ,

by , on February 24th, 2017

  • Categories