{"action":"created","issue":{"url":"https://api.github.com/repos/junit-team/junit5/issues/549","repository_url":"https://api.github.com/repos/junit-team/junit5","labels_url":"https://api.github.com/repos/junit-team/junit5/issues/549/labels{/name}","comments_url":"https://api.github.com/repos/junit-team/junit5/issues/549/comments","events_url":"https://api.github.com/repos/junit-team/junit5/issues/549/events","html_url":"https://github.com/junit-team/junit5/issues/549","id":184251609,"number":549,"title":"Selecting one method in JUnit4 parametrized test has no effect - test method is not executed.","user":{"login":"SqAutoTestTeam","id":22143150,"avatar_url":"https://avatars.githubusercontent.com/u/22143150?v=3","gravatar_id":"","url":"https://api.github.com/users/SqAutoTestTeam","html_url":"https://github.com/SqAutoTestTeam","followers_url":"https://api.github.com/users/SqAutoTestTeam/followers","following_url":"https://api.github.com/users/SqAutoTestTeam/following{/other_user}","gists_url":"https://api.github.com/users/SqAutoTestTeam/gists{/gist_id}","starred_url":"https://api.github.com/users/SqAutoTestTeam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SqAutoTestTeam/subscriptions","organizations_url":"https://api.github.com/users/SqAutoTestTeam/orgs","repos_url":"https://api.github.com/users/SqAutoTestTeam/repos","events_url":"https://api.github.com/users/SqAutoTestTeam/events{/privacy}","received_events_url":"https://api.github.com/users/SqAutoTestTeam/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-10-20T14:50:59Z","updated_at":"2016-10-27T22:07:33Z","closed_at":null,"body":"Example test code\r\n\r\n```java\r\nimport org.junit.Assert;\r\nimport org.junit.Test;\r\nimport org.junit.runner.RunWith;\r\nimport org.junit.runners.Parameterized;\r\n\r\nimport java.util.Arrays;\r\nimport java.util.Collection;\r\n\r\n/**\r\n * Created 20/10/16 16:51\r\n *\r\n * @author Vladimir Bogodukhov\r\n **/\r\n@RunWith(Parameterized.class)\r\npublic class JUnit4ParametrizedExample {\r\n\r\n    final boolean b;\r\n    final long l;\r\n    final int i;\r\n\r\n    @Parameterized.Parameters(name = \"{0} ---> : Test\")\r\n    public static Collection<Object[]> data() {\r\n        return Arrays.asList(new Object[][]{\r\n                {false, 1L, 21},\r\n                {true, 21L, 11},\r\n                {false, 10L, 21},\r\n        });\r\n    }\r\n\r\n    public JUnit4ParametrizedExample(boolean b, long l, int i) {\r\n        this.b = b;\r\n        this.l = l;\r\n        this.i = i;\r\n    }\r\n\r\n\r\n    @Test\r\n    public void test1() {\r\n        throw new IllegalStateException(); /* always fails */\r\n    }\r\n\r\n    @Test\r\n    public void test2() {\r\n        /* always succeed */\r\n    }\r\n}\r\n```\r\n\r\nTest code that provokes a bug.\r\n\r\n```java\r\nimport org.junit.Assert;\r\nimport org.junit.jupiter.api.Tag;\r\nimport org.junit.jupiter.api.Test;\r\nimport org.junit.platform.engine.TestExecutionResult;\r\nimport org.junit.platform.engine.discovery.DiscoverySelectors;\r\nimport org.junit.platform.launcher.*;\r\nimport org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder;\r\nimport org.junit.platform.launcher.core.LauncherFactory;\r\n\r\nimport java.util.HashMap;\r\nimport java.util.Map;\r\n\r\n/**\r\n * @author Vladimir Bogodukhov\r\n */\r\n@Tag(\"DebugRun\")\r\npublic class DynamicTestsHelperRun {\r\n\r\n    enum State {\r\n        skipped,\r\n        failed,\r\n        success,\r\n        aborted\r\n    }\r\n\r\n    @Test\r\n    void test1() {\r\n        Launcher launcher = LauncherFactory.create();\r\n\r\n        Map<State, Integer> callCounts = new HashMap<>();\r\n        launcher.registerTestExecutionListeners(new TestExecutionListener() {\r\n            @Override\r\n            public void executionSkipped(TestIdentifier identifier, String reason) {\r\n\r\n                if (identifier.isTest()) {\r\n                    callCounts.putIfAbsent(State.skipped, 0);\r\n                    callCounts.put(State.skipped, callCounts.get(State.skipped) + 1);\r\n                }\r\n            }\r\n\r\n            @Override\r\n            public void executionFinished(TestIdentifier identifier, TestExecutionResult result) {\r\n                if (identifier.isTest()) {\r\n                    State state = calcState(result);\r\n                    callCounts.putIfAbsent(state, 0);\r\n                    callCounts.put(state, callCounts.get(state) + 1);\r\n                }\r\n            }\r\n        });\r\n\r\n\r\n        final LauncherDiscoveryRequestBuilder builder = LauncherDiscoveryRequestBuilder.request();\r\n        builder.selectors(DiscoverySelectors.selectJavaClass(JUnit4ParametrizedExample.class));\r\n        LauncherDiscoveryRequest discoveryRequest = builder.build();\r\n\r\n        TestPlan discover = launcher.discover(discoveryRequest);\r\n        launcher.execute(discoveryRequest); \r\n        /* We call class with two parametrized methods - each method is called three times.  One test always fails another always succeed \r\n        And we get right result\r\n        */\r\n\r\n        Assert.assertEquals(new HashMap<State, Integer>() {\r\n            {\r\n                put(State.success, 3); /* Three succedd */\r\n                put(State.failed, 3);/* Three failed */\r\n            }\r\n        }, callCounts);\r\n    }\r\n\r\n\r\n    @Test\r\n        // Test that fails but certainly mustn't\r\n    void test2() {\r\n        Launcher launcher = LauncherFactory.create();\r\n\r\n        Map<State, Integer> callCounts = new HashMap<>();\r\n        launcher.registerTestExecutionListeners(new TestExecutionListener() {\r\n            @Override\r\n            public void executionSkipped(TestIdentifier identifier, String reason) {\r\n\r\n                if (identifier.isTest()) {\r\n                    callCounts.putIfAbsent(State.skipped, 0);\r\n                    callCounts.put(State.skipped, callCounts.get(State.skipped) + 1);\r\n                }\r\n            }\r\n\r\n            @Override\r\n            public void executionFinished(TestIdentifier identifier, TestExecutionResult result) {\r\n                if (identifier.isTest()) {\r\n                    State state = calcState(result);\r\n                    callCounts.putIfAbsent(state, 0);\r\n                    callCounts.put(state, callCounts.get(state) + 1);\r\n                }\r\n            }\r\n        });\r\n\r\n        final LauncherDiscoveryRequestBuilder builder = LauncherDiscoveryRequestBuilder.request();\r\n        builder.selectors(DiscoverySelectors.selectJavaMethod(JUnit4ParametrizedExample.class, \"test1\")); \r\n        LauncherDiscoveryRequest discoveryRequest = builder.build();\r\n\r\n        TestPlan discover = launcher.discover(discoveryRequest);\r\n        launcher.execute(discoveryRequest);\r\n        /* we select  test1() method that always fails */\r\n        \r\n\r\n\r\n        /* if we call to test method that fails three times it is logical to get three failures as result */\r\n        Assert.assertEquals(new HashMap<State, Integer>() {\r\n            {\r\n                put(State.failed, 3);/* Three failed */\r\n            }\r\n        }, callCounts);\r\n        /* However it is not so -  we get actually only one call.  and we do not stop at the breakpoint  in test code  */\r\n    }\r\n\r\n    private static State calcState(TestExecutionResult result) {\r\n        TestExecutionResult.Status status = result.getStatus();\r\n        switch (status) {\r\n            case ABORTED: {\r\n                return State.aborted;\r\n            }\r\n\r\n            case FAILED: {\r\n                return State.failed;\r\n            }\r\n\r\n            case SUCCESSFUL: {\r\n                return State.success;\r\n            }\r\n\r\n            default: {\r\n                throw new IllegalStateException(\"unknown state\");\r\n            }\r\n        }\r\n    }\r\n\r\n}\r\n```\r\n\r\ncall to `DiscoverySelectors.selectJavaMethod(JUnit4ParametrizedExample.class, JUnit4ParametrizedExample.class.getMethod(\"test1\"))` instead of `DiscoverySelectors.selectJavaMethod(JUnit4ParametrizedExample.class, \"test1\")` has the same effect\r\n"},"comment":{"url":"https://api.github.com/repos/junit-team/junit5/issues/comments/256783852","html_url":"https://github.com/junit-team/junit5/issues/549#issuecomment-256783852","issue_url":"https://api.github.com/repos/junit-team/junit5/issues/549","id":256783852,"user":{"login":"sbrannen","id":104798,"avatar_url":"https://avatars.githubusercontent.com/u/104798?v=3","gravatar_id":"","url":"https://api.github.com/users/sbrannen","html_url":"https://github.com/sbrannen","followers_url":"https://api.github.com/users/sbrannen/followers","following_url":"https://api.github.com/users/sbrannen/following{/other_user}","gists_url":"https://api.github.com/users/sbrannen/gists{/gist_id}","starred_url":"https://api.github.com/users/sbrannen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sbrannen/subscriptions","organizations_url":"https://api.github.com/users/sbrannen/orgs","repos_url":"https://api.github.com/users/sbrannen/repos","events_url":"https://api.github.com/users/sbrannen/events{/privacy}","received_events_url":"https://api.github.com/users/sbrannen/received_events","type":"User","site_admin":false},"created_at":"2016-10-27T22:07:33Z","updated_at":"2016-10-27T22:07:33Z","body":"What version of the JUnit Platform are you using?"}}
{"actor":{"display_login":"sbrannen"}}