This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 227317 - JUnit test skeletons - Parameterized test generation tool-tip
Summary: JUnit test skeletons - Parameterized test generation tool-tip
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: JUnit (show other bugs)
Version: 7.3
Hardware: All All
: P3 normal (vote)
Assignee: Theofanis Oikonomou
URL:
Keywords:
Depends on:
Blocks: 79352
  Show dependency tree
 
Reported: 2013-03-11 20:16 UTC by theshadow27
Modified: 2013-03-11 20:16 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description theshadow27 2013-03-11 20:16:30 UTC
per Bug 79352 :
Please describe/specify the skeletons you want to be generated:

Allow generation of parameterized tests. 

Current: IDE generates a skeleton for testing a single method invocation
Example:
    @Test
    public void testGetCode() {
        System.out.println("getCompute"); // See Feature #2
        MyObject instance = new MyObject(); // See Feature #3
        int x = 0;
        int expResult = 0;
        int result = instance.compute(x);
        assertEquals(expResult, result); // See Feature #1
    }

Enhancement: allow generation of parameterized tests for each method 
Example (using simple parameterization):
  
    @Test
    public void testCompute(){
        MyObject instance = new MyObject();
        paramCompute(instance, 0, 0);
        paramCompute(instance, 1, 1); // ... etc
    }
    /** Generated for testCompute() of MyObject **/ 
    private void paramTestCompute(Object instance, int expectedResult, int x){
        int result = instance.compute(x);
        assertEquals(expResult, result);
    }

Implementation Note: Perhaps this can be implemented as a tool-tip ("parameterize test case") 


JUnit4 @Parameterized does this, but it is much uglier (and probably harder to implement):

@RunWith(Suite.class)
@SuiteClasses(MyObjectTest.TestComputeSubtest.class)
public class MyObjectTest{

     /**
     * Test of compute method, of class MyObject.
     */
      @RunWith(Parameterized.class)
      public static class TestComputeSubtest { 
             private int expected;
             private int x;

             @Parameters
             public static Collection<Integer[]> getTestParameters(){...}

             public TestComputeSubtest(int expected, int x){
                  this.x = x;
                  this.expected = expected;
            }

            @Test
            public void testCompute(){
                  MyObject instance = getInstance();
                  int result = instance.compute(x);
                  assertEquals(expected, result);
            }
      }
}