Skip to content

EasyTest Codegen : Introduction

ravi-polampelli edited this page Dec 31, 2012 · 4 revisions

Easy Test Codegen is a tool to auto generate JUnit test cases in EasyTest format from source code. It also generates test data with default, boundary and user defined values. It reduces burden on developers by generating boiler-plate test cases and test data. Once generation is done, developer can modify those test cases or update test data etc.. This is developed based on Javadoc API and templates. The idea is taken from JUnitdoclet project. Please go through the introduction of EasyTest available at EasyTest - An Introduction

Features of EasyTest codegen:

  1. Templates provide flexibility to you to customize as per your needs and scenarios. For e.g. you can add code in BeforeClass method in template to setup the environment for tests. You can find sample template file with name JUnit4.properties in EasyTest-codegen source jar file.
  2. Filters : You can specify filters whether to include or not, such that test case generation will check for the existence of those filters(string value) in the methods and decide whether to include that in test case generation or not. By default it generates the test cases for all the public methods of source code. For e.g. if you want to test methods where queries are created using JPA createQuery method then you can mention below property in your property file. filter.include = criteriaBuilder.createQuery
  3. Overwrite test data: If you have added some test data to the test data file and made some changes to your source code, you want to generate the test cases again but you don not want to overwrite the existing test data. You can specify whether to overwrite the existing test data file or not. Codegen process will keep your existing data as per your preference.
  4. Overwrite converters: If you have modified the generated converters and keep them as it is.
  5. Seed data : You can provide seed data in a property file. In this file you can mention data as for your test scenarios like currency, country, customer, department ids etc... Codegen program takes the seed data and checks if it matches with parameter name. if it matches, then it takes the comma separated values into a list and add it to test data file. For e.g. property file entry could be CurrencyID = EUR,GBP,INR,USD
  6. Customize test case extension : By default "Test" extension is added to the test case file. But if you want to customize the extension you can do so, by adding simple property in template file Foe e.g : testcase.extension = JPATest

Output of codegen

  1. Junit test case in EasyTest format
  2. Test data file.
  3. Log file with information on missing data for parameters in each test method.