Unit Testing

Mocking static methods with PowerMock

A good developer always writes a unit test case for his/her code. While writing test cases, we came across various types of scenarios, including the one where we need to mock static methods. One of the common examples of such scenario is where our service is using some static methods from a third party library. Here, one way to deal is to have an adapter Continue Reading

Do you think your code is Perfect? Well, Think again.

“Any fool can write code that a computer can understand. Good programmers write code that humans can understand.” – Martin Fowler “I can code.” I always say to myself. But do others think the same? Is my code good enough for people to understand? Do other people think “Damn I wish I could write such code.?” –  that’s the main question I always had in Continue Reading

Knolx : Exploring the power of JMockit

Hello everyone, Knoldus organized a session on 22nd December 2017. The topic was “JMockit”. Many people attended and enjoyed the session. In this blog post, I am going to share the slides & video of the session. Slides: JMockit from Knoldus Inc. Video: If you have any query, then please feel free to comment below.

Difference between Mockito and JMockit

A Brief analysis on Mockito And Jmockit Mockito JMockit 1. We can achieve Static method/constructor mocking by the combination of Mockito with Powermock. 1. Static method/constructor can be mocked directly in JMockit. 2. The Mockito API contains several inconsistencies in the syntax used for invocations to mocked methods. In the record phase, we have calls like when(mock.mockedMethod(args))… while in the verify phase this same call Continue Reading

JMockit: A beginner’s guide for Unit Testing

So we are following TDD, And we are working on unit test cases, And then we are stuck with mocking. Well this was the situation we faced. And while going through various API tools for mocking, we came through this amazing toolkit: JMockit. What is JMockit? JMockit is open source software licensed under the MIT License. It includes APIs for mocking, faking, and integration testing, Continue Reading

Spark Streaming: Unit Testing DStreams

Frankly, I don’t think there’s any need of telling us, “The Developers”, the need for proper testing or Unit testing to be correct(QAs, Don’t be flattered :P). The unit test cases are the quickest way to know there’s something wrong with our code. “Unit testing is important because it is one of the earliest testing efforts performed on the code and the earlier defects are detected, the easier Continue Reading

Unit Testing vs. Component Testing in Lagom

Let’s first understand the basic difference between unit testing and component testing and then we will have a look at a practical application of unmanaged service in lagom with its test cases. Difference between Unit Testing and Component Testing Unit Testing involves testing of individual units(classes) to demonstrate that the program executes as per the specification and it validates the design and technical quality of Continue Reading

Generating, visiting and unit testing grammar using ANTLR4 with Java and Scala

“Quality is free, but only to those who are willing to pay heavily for it” – T. DeMarco Now unit testing is not that heavy to pay off so lets start the blog. In this blog we will be continuing the voyage to the kingdom of ANTLR4 RECAP In previous blog we discussed how to test whether a string is grammatically correct or not using Continue Reading

KnolX: Unit Testing of Spark Applications

Knoldus organized a KnolX session on Wednesday, 13 April 2016. In this KnolX session, we explored the different methods of writing unit tests for Spark applications. This session also talks about how unit testing of Spark applications is done, as well as tells about the best way to do it. This includes writing unit tests with and without Spark Testing Base package, which is a spark Continue Reading

Mock Unit Testing using Mockito in Play Scala project

During Unit Testing in a Play Scala project, there arises a need to Mock certain Objects or Traits which are used in the unit, so that the unit being tested has a consistent interaction with its outside dependencies. But due to tight coupling or external dependencies, objects cannot be tested as a unit. So, we need to mock those external dependencies by adding fake external Continue Reading

Unit Testing Maven Based JPA Application on GAE

Recently, we started porting a complex enterprise timesheet and invoicing application to Google App Engine. We would talk about the strategy that we are following as a part of separate post but in this post let us look at how we can unit test JPA code effectively in our local environment. By the way, the application that we are porting does not use JPA but Continue Reading

Unit Testing Esper Statements

Esper Statements would allow the flow of events to pass through them. Usually what would you like to unit test for a basic scenario? The valid events are being passed to the listener The invalid events are filtered out and are not passed to the listener The batching time, if defined for the statement, is being adhered to. Let us quickly look at what a Continue Reading

%d bloggers like this: