{"action":"opened","issue":{"url":"https://api.github.com/repos/DiUS/pact-jvm/issues/349","repository_url":"https://api.github.com/repos/DiUS/pact-jvm","labels_url":"https://api.github.com/repos/DiUS/pact-jvm/issues/349/labels{/name}","comments_url":"https://api.github.com/repos/DiUS/pact-jvm/issues/349/comments","events_url":"https://api.github.com/repos/DiUS/pact-jvm/issues/349/events","html_url":"https://github.com/DiUS/pact-jvm/issues/349","id":193074859,"number":349,"title":"JUnit failing with requests not received","user":{"login":"lordofthejars","id":1517153,"avatar_url":"https://avatars.githubusercontent.com/u/1517153?v=3","gravatar_id":"","url":"https://api.github.com/users/lordofthejars","html_url":"https://github.com/lordofthejars","followers_url":"https://api.github.com/users/lordofthejars/followers","following_url":"https://api.github.com/users/lordofthejars/following{/other_user}","gists_url":"https://api.github.com/users/lordofthejars/gists{/gist_id}","starred_url":"https://api.github.com/users/lordofthejars/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lordofthejars/subscriptions","organizations_url":"https://api.github.com/users/lordofthejars/orgs","repos_url":"https://api.github.com/users/lordofthejars/repos","events_url":"https://api.github.com/users/lordofthejars/events{/privacy}","received_events_url":"https://api.github.com/users/lordofthejars/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-12-02T09:50:38Z","updated_at":"2016-12-02T09:50:38Z","closed_at":null,"body":"Hello, I am facing one problem that maybe it is normal but I would like to be sure that it is not a bug. Currently I have my JUnit test that defines the PactFragment like:\r\n\r\n```\r\nreturn builder\r\n                .uponReceiving(\"User older than PEGI description\")\r\n                    .path(\"/checker/\")\r\n                    .method(\"POST\")\r\n                    .headers(headers)\r\n                    .body(toJson(\r\n                            \"{                  \" +\r\n                            \"  'age': 18,       \" +\r\n                            \"  'pegi': 'PEGI_16'\" +\r\n                            \"}\")\r\n                    )\r\n                .willRespondWith()\r\n                    .status(200)\r\n                    .body(\"OK\", ContentType.TEXT_PLAIN)\r\n                .uponReceiving(\"User younger than PEGI description\")\r\n                .path(\"/checker/\")\r\n                .method(\"POST\")\r\n                .headers(headers)\r\n                .body(toJson(\r\n                        \"{                  \" +\r\n                                \"  'age': 16,       \" +\r\n                                \"  'pegi': 'PEGI_18'\" +\r\n                                \"}\")\r\n                )\r\n                .willRespondWith()\r\n                .status(200)\r\n                .body(\"NO_OK\", ContentType.TEXT_PLAIN)\r\n            .toFragment();\r\n```\r\n\r\nSo as you can see this fragment contains two interactions.\r\n\r\nThen I have two tests, one that tests the first `uponReceiving` part and another one that tests the second `uponReceiving` interaction.\r\n\r\nThe problem is that when you run the first test it fails because the second interaction were not received and the same for the second one against the first.\r\n\r\nSo if you want to use this approach you need to create a single test that verifies at the same test both scenarios, which it seems a bad practice in terms of writing tests since in theory in each test you should only test one thing, but in this case you are testing two things.\r\n\r\n```\r\n@Test\r\npublic void test() {\r\n  testYoungerThanPegi();\r\n  testOlderThanPegi();\r\n}\r\n```\r\n\r\nNotice that you are asserting two different scenarios in same test instead of:\r\n\r\n```\r\n@Test\r\npublic void test1() {\r\n  testYoungerThanPegi();\r\n}\r\n@Test\r\npublic void test2() {\r\n  testOlderThanPegi();\r\n}\r\n```\r\n\r\nNotice that now each tests asserts one thing.\r\n\r\nSo obviously the solution I have found for now is to use several fragments so each test verifies one thing. Is this the expected behaviour to work with?"}}
{"actor":{"display_login":"lordofthejars"}}