From: SourceForge.net <no...@so...> - 2009-12-01 02:20:27
|
Feature Requests item #1707887, was opened at 2007-04-26 08:09 Message generated for change (Settings changed) made by sf-robot You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=365278&aid=1707887&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: Torsten Marek (shlomme) Assigned to: Nobody/Anonymous (nobody) Summary: [Patch] Runner for mixing parameterized and normal tests Initial Comment: Hi, the attached archive contains a special runner called "EnhancedRunner" that supports mixing "traditional" test cases (public void, no arguments) with parameterized test cases, which can now be public void methods that take arguments. An example: class StringTest { @Test public void testConcat() { assertEquals("ab", "a" + "b"); } @ParamTest("strings") public void testLength(String s, int length) { assertEquals(length, s); } public static Collection<Object[]> strings() { return Arrays.asList(new Object[][] { {"foo", 3}, {"foo bar", 7}, {"", 0}}); } } The runner will collect methods with @Test annotations as well as @ParamTest ones. For a @ParamTest, it will use the methods whose name is contained in the value (which has to be a public static method that returns an Iterable<Object[]>) to obtain the arguments for the invocations. This approach has several advantages over the "Parameterized" runner in JUnit 4.x: - normal tests and parameterized tests can be mixed in one class, no need to create several separate unit test classes - the method is invoked directly instead of first creating the class - in this case, the test class needs to keep references to the parameters. Of course, if a whole test suite depends on parameters, the Parameterized runner is to be prefered. This parameters are also put into the description of the test, thus it is possible to see which set of parameters triggered a test failure. This would also be a useful enhancement for the Parameterized runner. A helper method to neatly format argument lists is contained in the helper class ParameterUtils, which also contains some methods to split vararg arrays of length n*m into n arrays of length m, which is useful for creating argument lists. Currently, there is one external dependency on StringUtils.join from Commons Lang, which can easily be removed. with best regards, Torsten Marek, FAST Search & Transfer ---------------------------------------------------------------------- >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: CoSoCo (cosoco) Date: 2008-08-28 13:23 Message: Logged In: YES user_id=1040495 Originator: NO Very nice work !!! I like to suggest, to change the annotation identifier from: @ParamTest to: @ParamsTest Regards, Ulf ---------------------------------------------------------------------- Comment By: FARKAS Mt (fmate14) Date: 2008-03-15 14:40 Message: Logged In: YES user_id=1698060 Originator: NO Very good idea, thank you! ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=365278&aid=1707887&group_id=15278 |