Unit Testing: EAMSteps
Unit Testing: EAMSteps
Join the DZone community and get the full member experience.Join For Free
How do you break a Monolith into Microservices at Scale? This ebook shows strategies and techniques for building scalable and resilient microservices.
I came across this article on Dzone, which is just right to set the tone for me to release my latest code, which I find myself to be very proud of. The article speaks about the importance of Unit Testing for developers and how it can save the day for you especially when you are moving into Integration phase of the application. My first encounter with Unit Testing was back in 2004 and it was not just any kind of Unit Testing, it was fully automated Unit Testing using JUnit and NUnit. To add to the mix it was Test Driven Development (TDD). When I started with unit testing it was really frustrating and coding just took time. I knew that my logic was right and yet I had to write test cases. I was going through the motions until after 4 months our Architect told us that we need to a major refactoring. It was then that I saw how useful those test cases were. As we went about changing the implementations of Data Access Objects, we knew all was well once we were able to get the Unit Test cases to pass. And, from that day onwards I was addicted.
I was working with a client in Agile mode and had a team of 40 developers who cranked 1000s of lines of code (LOC) every day and those LOCs included unit test cases. Given the nature and size of the project it was evident that I wanted TDD model for the project delivery and for the following main reasons:
- We wanted test cases to double up as requirements;
- We wanted our Quality Assurance (QA) team to actively participate in test data formation so that we can reduce the gap between our developers and testers;
- We wanted to externalize test data from Unit Test cases so that new data could be added without changing the code (Test code) and different scenarios could be executed based on the test data
Approach – Where we failed
We started with the following:
- TestNG: TestNG had support for data provides which allowed us to pass data during invocation of the test methods
- Used XML files for dbSetup and initialization. We created custom classes that allowed us to read data from XML files and run queries against database from within the test cases
- JIBX Dataprovider: We used JIBX Data provider to pass the data into TestNG during test execution. This provided expected us to map inputs and output data in XML format
However, after just few months, we realized that these choices were not helping us in achieving our goals. The entire setup was too complex and too developer oriented that we could not take it to client. Also, for the QA team it was too much of an overhead to manage all of those files. However, it was too late in the game to change anything and our development team was now getting experienced with the tools and framework. We just did not have time to replace the whole thing at the cost of refactoring and training the team on the new framework. Another problem was that there was no open source and free tool or framework that existed that allowed us to do that (this was back in 2007).
In 2008, I got so fed up with the underlying choices that I decided that this is something I would not use. The only piece I loved was TestNG – Eclipse integration, Maven integration and Data providers just made life so much easier. JUnit later added the capability for Parametrized Unit Testing, but it had certain shortfalls (I compared the two a while back, you can find the article here). In 2009, I decided that in long term I would need to have a framework in place that will help me meet my objectives and I started to look for any existing tools. I do not have my research results, but I did not find any framework that allowed me to do what I wanted (at least nothing open source and free). Even today when I search I find the following links. There is not much that they offer. Or maybe I am just not seeing those.
- Approach to use Excel with Parametrised Unit Tesitng with JUnit)
- DDSteps: This comes close to what I wanted to do, but this has been built for JUnit which was not choice of unit testing tool. Since then they have come a long way. Their current version of website was non-existent back then and documentation was missing then and it is missing now. Hence, I did not want to reply on something that could be buggy and a project that may be closed
- The biggest drawback in this framework was that it did not support child objects in Java objects. If my parent Java Object had a child object, I had to load the parent and children java objects separately and then set them manually in my test case
So I started to visualize what I needed and it was then that I conceived this framework or set of utility classes.
I have tried to keep it very simple and the result is – EAMSteps:
- External data store for test data like excel spreadsheet
- Automated assertions using co-related inputs and outputs
- Minimal lines of code to get started
- I have the basic structure of the project ready and it supports loading the data from Excel sheets only for certain data types;
- The project can be downloaded from the repository and you can use it or extend it;
- Registration with Maven Central is pending; hoping to do that in a few days;
- The documentation is only around JavaDocs API and is available here;
- Project will be hosted on http://eamsteps.com, which will by end of this month and will have all relevant documentation
If you have any inputs or suggestions, please add your comments and let me know.
Opinions expressed by DZone contributors are their own.