Skip to content

Commit

Permalink
Handle parameterized unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
rjust committed Sep 9, 2024
1 parent 1bcd5c6 commit 6606efc
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
Binary file modified framework/lib/formatter.jar
Binary file not shown.
1 change: 1 addition & 0 deletions framework/lib/formatter/expected-output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
--- edu.washington.cs.mut.testrunner.junit4.EmptyTestClass
--- edu.washington.cs.mut.testrunner.junit4.InitError
--- edu.washington.cs.mut.testrunner.junit4.MethodTimeout::test2
--- edu.washington.cs.mut.testrunner.junit4.ParamTest::testWithParams
--- edu.washington.cs.mut.testrunner.junit4.NonJUnitTest
--- edu.washington.cs.mut.testrunner.junit4.NotPublicSuite
--- edu.washington.cs.mut.testrunner.junit4.SimpleTest::test2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ private void handle(Test test, Throwable t) {

className = test.getClass().getName();
{
Pattern regexp = Pattern.compile("(.*)\\((.*)\\)\\s*");
Pattern regexp = Pattern.compile("([^\\[\\(]*)(\\[.*\\])?\\((.*)\\)\\s*");
Matcher match = regexp.matcher(test.toString());
if (match.matches()) {
// Class name will equal to junit.framework.Junit4TestCaseFacade if Junit4
// style tests are ran with Junit3 style test runner.
if(className.equals("junit.framework.JUnit4TestCaseFacade"))
className = match.group(2);
className = match.group(3);
methodName = match.group(1);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package edu.washington.cs.mut.testrunner.junit4;

import static org.junit.Assert.assertTrue;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

@RunWith(Parameterized.class)
public class ParamTest {

private Integer testNo;

public ParamTest(Integer n) {
this.testNo = n;
}

@Parameters
public static Collection<Object[]> params() {
final List<Object[]> list = new ArrayList<Object[]>(3);
list.add(new Integer[] {1});
list.add(new Integer[] {2});
list.add(new Integer[] {3});
return list;
}

@Test
public void testWithParams() {
assertTrue(false);
}
}

0 comments on commit 6606efc

Please sign in to comment.