{"action":"created","issue":{"url":"https://api.github.com/repos/philsquared/Catch/issues/603","repository_url":"https://api.github.com/repos/philsquared/Catch","labels_url":"https://api.github.com/repos/philsquared/Catch/issues/603/labels{/name}","comments_url":"https://api.github.com/repos/philsquared/Catch/issues/603/comments","events_url":"https://api.github.com/repos/philsquared/Catch/issues/603/events","html_url":"https://github.com/philsquared/Catch/issues/603","id":138240092,"number":603,"title":"Preconditions","user":{"login":"timonbaetz","id":4034374,"avatar_url":"https://avatars.githubusercontent.com/u/4034374?v=3","gravatar_id":"","url":"https://api.github.com/users/timonbaetz","html_url":"https://github.com/timonbaetz","followers_url":"https://api.github.com/users/timonbaetz/followers","following_url":"https://api.github.com/users/timonbaetz/following{/other_user}","gists_url":"https://api.github.com/users/timonbaetz/gists{/gist_id}","starred_url":"https://api.github.com/users/timonbaetz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timonbaetz/subscriptions","organizations_url":"https://api.github.com/users/timonbaetz/orgs","repos_url":"https://api.github.com/users/timonbaetz/repos","events_url":"https://api.github.com/users/timonbaetz/events{/privacy}","received_events_url":"https://api.github.com/users/timonbaetz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-03-03T17:12:29Z","updated_at":"2016-03-03T17:39:24Z","closed_at":null,"body":"Is there a recommended way to execute the same set of checks with different preconditions?\r\n\r\nSomething like: \r\n```\r\nTEST_CASE(\"Test foo\")\r\n{\r\n    Foo foo;\r\n    foo.setBar(\"bar\");\r\n    REQUIRE(foo.hasBar());\r\n    REQUIRE(foo.isValid());\r\n\r\n    foo.setBar(\"baz\");\r\n    REQUIRE(foo.hasBar());\r\n    REQUIRE(foo.isValid());\r\n\r\n    foo.setBar(\"bazzz\");\r\n    REQUIRE(foo.hasBar());\r\n    REQUIRE(foo.isValid());\r\n}\r\n```\r\nbut without the code duplication?"},"comment":{"url":"https://api.github.com/repos/philsquared/Catch/issues/comments/191878485","html_url":"https://github.com/philsquared/Catch/issues/603#issuecomment-191878485","issue_url":"https://api.github.com/repos/philsquared/Catch/issues/603","id":191878485,"user":{"login":"timonbaetz","id":4034374,"avatar_url":"https://avatars.githubusercontent.com/u/4034374?v=3","gravatar_id":"","url":"https://api.github.com/users/timonbaetz","html_url":"https://github.com/timonbaetz","followers_url":"https://api.github.com/users/timonbaetz/followers","following_url":"https://api.github.com/users/timonbaetz/following{/other_user}","gists_url":"https://api.github.com/users/timonbaetz/gists{/gist_id}","starred_url":"https://api.github.com/users/timonbaetz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timonbaetz/subscriptions","organizations_url":"https://api.github.com/users/timonbaetz/orgs","repos_url":"https://api.github.com/users/timonbaetz/repos","events_url":"https://api.github.com/users/timonbaetz/events{/privacy}","received_events_url":"https://api.github.com/users/timonbaetz/received_events","type":"User","site_admin":false},"created_at":"2016-03-03T17:39:24Z","updated_at":"2016-03-03T17:39:24Z","body":"Thx @lightmare  that is what I am doing right now (more or less) but i thought maybe there is a better way\r\n\r\n```\r\nfor (auto val : {\"bar\", \"baz\", \"bazzz\"}) {\r\n    SECTION(\"Testing foo with \" + val)\r\n    {\r\n        Foo foo;\r\n        foo.setBar(val);\r\n        CHECK(foo.hasBar());\r\n        CHECK(foo.isValid());\r\n    }\r\n}\r\n```\r\n\r\nThings get a little bit ugly when I need to change more that one member of foo or maybe call some other functions in one of the tests. Lets say i want to test foo after calling setBar, the i want to check foo after calling setBar() and some other function"}}