Sunday, 1 March 2015

Confab with Testing frameworks for Compelling lineaments

This time I am going to stress upon some TESTING approaches, which we often follow, while creating unit tests cases of our code. Creating Unit Tests of our code is one of the most important phases of the Software Development Life Cycle and so the test cases should be created in such a way that our functionality gets properly tested with all possible path flows. Now, for testing purposes the most common and widely used Testing Framework in Java is JUnit. Its seamless integration with different Java Based Frameworks especially Spring (with the help of different RUNNERS) makes it a DEARIE. One of the ineresting and useful feature of Junit Tests is the Parameterized way of Testing. While during JUnit Testing, we compare the expected result with the actual result using different Assert statements, which matches actual result with the expected result. Hamcrest is a framework for writing matcher objects allowing 'match' rules to be defined declaratively. The assertThat method is a stylized sentence for making a test assertion. Here is a brief discussion on the topic. Recently, I am trying to learn Groovy features. So, decided to transform the JUnit Parameterized Test Cases to Groovy and after transformation I found it really interesting. Groovy with all its dynamicity and lot of resourceful operators is really interesting.Let's find it out. Recently, I am having my first encounter with Groovy, I am learning it and Groovy with its loads of mind blowing features does gives me a lot of interest, & I will share my experience with Groovy in a separate link. Here, all I wanted to part is my confab with Spock, a testing framework for Groovy. While using it, I have really become a fan of it , believe me and you would too become so once to get acquainted with it. Mocking is a important feature while doing unit Testing. Now the question arises what is mocking and why should we use mocking? While doing unit Testing, we often come across scenarios where we find that our code is dependent on some third party implementation or some other functionalities which are actually not a part of the block of code to be unit tested, so most often we would like to mimic or mock those features so that we could proceed on with our Test cases. Mocking with PowerMock is indeed a powerful feature. Recently while I was testing a class that has got some dependent objects autowired in it(Spring), I thought of using some features other than PowerMock, then I came to know of the following.
View Subhankar Paul's profile on LinkedIn

No comments:

Post a Comment