GenerateTestCases

Compatible with IntelliJ IDEA
19.01.2013
8 299

Plugin to generate unit test methods with meaningful names based in described behaviours with @should tags in interface methods javadoc

To see how to use it: http://elespaciodejaime.wordpress.com/2011/05/29/generate-test-cases-intellij-plugin/ or http://plugins.intellij.net/plugin/?idea&id=5847 or for a usage video http://www.youtube.com/watch?v=WYET6PECxuc

Credits for the @should style testing should go to OpenMRS team

Download plugin

Recent change notes

1.0.9

  • Fixed to work with IntelliJ IDEA 12 (thanks to nribeka)

1.0.8

  • Added support for TestNG testing framework

1.0.7

  • Fixed @should descriptions renaming support for IntelliJ IDEA 11

1.0.6

  • Version number increased to update jar in Intellij plugins site

1.0.5

  • Fixed bug when custom source root has been configured# but not created yet

1.0.4

  • Added CTRL+Click functionality to jump to test cases

General usage instructions

Generates Test Cases is a port of Eclipse's generate test cases plugin described here:

http://wiki.openmrs.org/display/archive/Generate+Test+Case+Eclipse+Plugin

You can see a 10 minutes video to grasp the concept in a really easy way here:


http://www.youtube.com/watch?v=WYET6PECxuc

This project aims to make it easier to make TDD with a really cool and easy approach that consist in annotating interface method with desired behaviours like this:



public interface Person {

/**
* @return
* @should say hello, and nothing more that that
*/
String sayHello();

}

So with this plugin you could generate a test class for this interface like this one automatically:



public class PersonTest extends TestCase {
/**
* @verifies say hello, and nothing more that that
* @see Person#sayHello()
*/
public void testSayHello_shouldSayHelloAndNothingMoreThatThat() throws Exception {
//TODO auto-generated
Assert.fail("Not yet implemented");
}
}

And then test your implementation code like this



public void sayHello_shouldSayHelloAndNothingMoreThatThat() throws Exception {
assertThat(instance.sayHello(), is("hello world"));
}

This way you can realize that for testing this behaviour you just wrote the should annotation in the sut (system under test) in a really descriptive way.



@should say hello, and nothing more that that

Auto-generated the test class and test method (using the plugin) and then tested the actual expected behaviour with (hamcrest style junit test):



assertThat(intance.sayHello(), is("hello world"));

Usage Instructions:

Open class in editor and press the "Generate Test Methods" button in toolbar to generate test methods for @should style annotations added to methods in javadoc