Does the SpiraTest JUnit integration library support parameterized tests?

Wednesday, April 29, 2015
Avatar
Hello,

I'm using the JUnit integration with JUnit. It's working fine for my normal test cases and test result are transmitted to SpiraTest. 

Now, I'am adding parametrized tests which is a feature of JUnit 4. When I add the SpiraTest annotation to a parametrized test, and run it with the Main class as documented in the SpiraTest Automated Testing Integration Guide, it fails. I get the following error messages:
java.lang.NoSuchMethodException: org.test.FibonacciTest.test[0]()

Does the SpiraTest JUnit integration library support parameterized tests?

Here is my code to give you an idea what I try to accomplish:
@RunWith(Parameterized.class)
@SpiraTestConfiguration(url = URL, login = USER, password = PWD, projectId = PROJECT_ID)
public class FibonacciTest {

    @Parameters
    public static Collection<Object[]> data() {
        return Arrays.asList(new Object[][] { { 0, 0 }, { 1, 1 }, { 2, 1 }, { 3, 2 }, { 4, 3 }, { 5, 5 }, { 6, 8 } });
    }

    private int fInput;

    private int fExpected;

    public FibonacciTest(int input, int expected) {
        fInput = input;
        fExpected = expected;
    }

    @Test
    @SpiraTestCase(testCaseId=21966)
    public void test() {
        assertEquals(fExpected, compute(fInput));
    }

    private int compute(int fInput2) {
        return 1;
    }
}


public class SpiraApplicationMain {

    public final static String URL = "";
    public final static String USER = ";
    public final static String PWD = "";
    public final static int PROJECT_ID = 0;

    /**
     * Entry point for command line execution
     * 
     * @param args
     *            The command line arguments
     */
    public static void main(String[] args) {
        // Instantiate the JUnit core
        JUnitCore core = new JUnitCore();

        // Add the custom SpiraTest listener
        core.addListener(new SpiraTestListener());

        // Finally run the test fixture
        core.run(FibonacciTest.class);
    }

    /**
     * Entry point for JUnit 4.x runners
     *
     * @return Handle to the test framework
     */
    public static junit.framework.Test suite() {
        return new JUnit4TestAdapter(FibonacciTest.class);
    }
}

Regards,
Rene

1 Replies
Tuesday, May 5, 2015
Avatar
re: rene.mischak Wednesday, April 29, 2015

Hi Rene

I have checked with our team and it was not developed with that feature in mind, so there is a possibility that it will not work with such tests.

Regards

Adam

Spira Helps You Deliver Quality Software, Faster and With Lower Risk

And if you have any questions, please email or call us at +1 (202) 558-6885

 

Statistics
  • Started: Wednesday, April 29, 2015
  • Last Reply: Tuesday, May 5, 2015
  • Replies: 1
  • Views: 8239