From: SourceForge.net <no...@so...> - 2009-12-01 02:20:27
|
Feature Requests item #1674180, was opened at 2007-03-05 15:49 Message generated for change (Comment added) made by sf-robot You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=365278&aid=1674180&group_id=15278 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None >Status: Closed Resolution: None Priority: 5 Private: No Submitted By: Jonhnny Weslley (jweslley) Assigned to: David Saff (dsaff) Summary: To support test methods with injection of parameters Initial Comment: Recently, I need of parameterized test methods, then used a Parameterized runner, but this uses constructor injection of parameters, and my unit test has many test methods with distinct types. Then I was create a ParameterizedMethod runner, which uses method injection of parameters - parameterized test methods. The parameterized test methods requires a ParametersSource annotation, this annotation requires the parameters source method name. The parameters source method to must be no arguments, public, static, and, finally, to return a Collection or a array. However, to support this feature requires two little changes in junit: 1) org.junit.internal.runners.MethodValidator class renamed to TestClassValidator. The TestClassValidator is more extensible than MethodValidator, which allow to create a ParameterizedMethodValidator class, required for the new feature. 2) To add the TestClassValidator's factory method - createTestClassValidator method - at org.junit.internal.runners.TestClassRunner class. The junit-parameterized-method.zip file has a copy from TestClassRunner class - called TestClassRunner2 - added of the createTestClassValidator method. USAGE: ... @Test @ParametersSource("numbersEq") // refer to numbersEq method public void checkGreaterThan(int x, int y) { assertTrue("x lower than y", x < y); } public static Integer[][] numbersEq() { return new Integer[][] { {1, 2}, {2, 3}, {3, 4}, {4, 5}, {5, 6}}; } ... ---------------------------------------------------------------------- >Comment By: SourceForge Robot (sf-robot) Date: 2009-12-01 02:20 Message: This Tracker item was closed automatically by the system. It was previously set to a Pending status, and the original submitter did not respond within 14 days (the time period specified by the administrator of this Tracker). ---------------------------------------------------------------------- Comment By: David Saff (dsaff) Date: 2009-11-16 17:52 Message: This tracker is being shut down. Please move this item to http://github.com/KentBeck/junit/issues ---------------------------------------------------------------------- Comment By: Alex (toalexsmail) Date: 2008-03-12 21:34 Message: Logged In: YES user_id=2034775 Originator: NO See related http://sourceforge.net/tracker/index.php?func=detail&aid=1626414&group_id=15278&atid=365278 ---------------------------------------------------------------------- Comment By: David Saff (dsaff) Date: 2007-04-12 20:12 Message: Logged In: YES user_id=325156 Originator: NO Jonhnny, could you attach your changes as a patch so we can review it more easily? Thanks. ---------------------------------------------------------------------- Comment By: Jonhnny Weslley (jweslley) Date: 2007-04-09 17:35 Message: Logged In: YES user_id=1627927 Originator: YES I realize some refactorings in junit-4.3.1 to support this feature. Changes: - Replacement of org.junit.internal.runners.MethodValidator class by org.junit.internal.runners.TestClassValidator class. - Introduce factory method createTestClassValidator in org.junit.internal.runners.TestClassRunner class - Introduce runner: org.junit.runners.ParameterizedMethod - Include a sample test class: org.junit.runners.IntDateTimeTest File Added: junit.jar ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=365278&aid=1674180&group_id=15278 |