Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating Unit Tests Automatically

I have a web tool which when queried returns generated Java classes based upon the arguments in the URL.

The classes we retrieve from the webserver change daily and we need to ensure that they still can process known inputs.

Note these classes do not test the webserver, they run locally and transform xml into a custom format. I am not testing the webserver.

These classes must then be placed in specific package structure compiled and run against a known set of input data and compared against known output data.

I would like to do this automatically each night to make sure that the generated classes are correct.

What is the best way to achieve this?

Specifically whats the best way to:

  1. retrieve the code from a webserver and place it in a file
  2. compile the code and then call it

I'm sure a mix of junit and ant will be able to achieve this but is there and standard solution / approach for this?

like image 625
Neil Foley Avatar asked Oct 15 '22 10:10

Neil Foley


1 Answers

First up, to answer your question: No, I do not think that there is a standard approach for this. This sounds like quite an unusual situation ;-)

Given that, what I would do is to write your JUnit tests to all call a class GeneratedCode, and then, once you download the code, rename the class to GeneratedCode, compile, and run your unit tests.

like image 101
Paul Wagland Avatar answered Oct 18 '22 15:10

Paul Wagland