{"action":"created","issue":{"url":"https://api.github.com/repos/SpectoLabs/hoverfly-java/issues/123","repository_url":"https://api.github.com/repos/SpectoLabs/hoverfly-java","labels_url":"https://api.github.com/repos/SpectoLabs/hoverfly-java/issues/123/labels{/name}","comments_url":"https://api.github.com/repos/SpectoLabs/hoverfly-java/issues/123/comments","events_url":"https://api.github.com/repos/SpectoLabs/hoverfly-java/issues/123/events","html_url":"https://github.com/SpectoLabs/hoverfly-java/issues/123","id":237489537,"number":123,"title":"HoverflyRule doesn't export simulations for multiple tests","user":{"login":"tommysitu","id":7671879,"avatar_url":"https://avatars2.githubusercontent.com/u/7671879?v=4","gravatar_id":"","url":"https://api.github.com/users/tommysitu","html_url":"https://github.com/tommysitu","followers_url":"https://api.github.com/users/tommysitu/followers","following_url":"https://api.github.com/users/tommysitu/following{/other_user}","gists_url":"https://api.github.com/users/tommysitu/gists{/gist_id}","starred_url":"https://api.github.com/users/tommysitu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tommysitu/subscriptions","organizations_url":"https://api.github.com/users/tommysitu/orgs","repos_url":"https://api.github.com/users/tommysitu/repos","events_url":"https://api.github.com/users/tommysitu/events{/privacy}","received_events_url":"https://api.github.com/users/tommysitu/received_events","type":"User","site_admin":false},"labels":[{"id":333798387,"url":"https://api.github.com/repos/SpectoLabs/hoverfly-java/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-06-21T10:36:04Z","updated_at":"2018-03-12T11:19:42Z","closed_at":null,"author_association":"OWNER","body":"When HoverflyRule is annotated with `@Rule`, the `exportSimulation` is called after each test, meaning that, it will keep overwriting old captured data because of the same filename. \r\n\r\nThe solution could be postfixing the file name with the test class names, so that\r\n```\r\n@Rule\r\npublic HoverflyRule hoverflyRule = HoverflyRule.inCaptureMode(\"booking_service_test.json\")\r\n\r\n@Test \r\npublic shouldGetBooking() {\r\n}\r\n\r\n@Test\r\npublic shouldDeleteBooking() {\r\n}\r\n```\r\n\r\nshould create two files under `test/resources/hoverfly`\r\n- `booking_service_test_shouldGetBooking.json`\r\n- `booking_service_test_shouldDeleteBooking.json`"},"comment":{"url":"https://api.github.com/repos/SpectoLabs/hoverfly-java/issues/comments/372276372","html_url":"https://github.com/SpectoLabs/hoverfly-java/issues/123#issuecomment-372276372","issue_url":"https://api.github.com/repos/SpectoLabs/hoverfly-java/issues/123","id":372276372,"user":{"login":"tommysitu","id":7671879,"avatar_url":"https://avatars2.githubusercontent.com/u/7671879?v=4","gravatar_id":"","url":"https://api.github.com/users/tommysitu","html_url":"https://github.com/tommysitu","followers_url":"https://api.github.com/users/tommysitu/followers","following_url":"https://api.github.com/users/tommysitu/following{/other_user}","gists_url":"https://api.github.com/users/tommysitu/gists{/gist_id}","starred_url":"https://api.github.com/users/tommysitu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tommysitu/subscriptions","organizations_url":"https://api.github.com/users/tommysitu/orgs","repos_url":"https://api.github.com/users/tommysitu/repos","events_url":"https://api.github.com/users/tommysitu/events{/privacy}","received_events_url":"https://api.github.com/users/tommysitu/received_events","type":"User","site_admin":false},"created_at":"2018-03-12T11:19:42Z","updated_at":"2018-03-12T11:19:42Z","author_association":"OWNER","body":"@ia3andy, I think this is due to the limitation of JUnit 4. Ideally, we want to start and stop Hoverfly for the whole test suite once, and also be able to import/export different simulation per test. There are a few options I can think of:\r\n\r\n- Call Hoverfly API manually\r\n- Use JUnit 5 [HoverflyExtension](http://hoverfly-java.readthedocs.io/en/latest/pages/junit5/extension.html#)\r\n- Use `@ClassRule` to manage Hoverfly lifecycle, and use a separate `@Rule` to import/export simulation files for each test. "}}
{"actor":{"display_login":"tommysitu"}}