{"action":"created","issue":{"url":"https://api.github.com/repos/dart-lang/test/issues/163","labels_url":"https://api.github.com/repos/dart-lang/test/issues/163/labels{/name}","comments_url":"https://api.github.com/repos/dart-lang/test/issues/163/comments","events_url":"https://api.github.com/repos/dart-lang/test/issues/163/events","html_url":"https://github.com/dart-lang/test/issues/163","id":85654813,"number":163,"title":"Asynchronous test failures cause cascading bugs in asynchronous tests","user":{"login":"DartBot","id":8958862,"avatar_url":"https://avatars.githubusercontent.com/u/8958862?v=3","gravatar_id":"","url":"https://api.github.com/users/DartBot","html_url":"https://github.com/DartBot","followers_url":"https://api.github.com/users/DartBot/followers","following_url":"https://api.github.com/users/DartBot/following{/other_user}","gists_url":"https://api.github.com/users/DartBot/gists{/gist_id}","starred_url":"https://api.github.com/users/DartBot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DartBot/subscriptions","organizations_url":"https://api.github.com/users/DartBot/orgs","repos_url":"https://api.github.com/users/DartBot/repos","events_url":"https://api.github.com/users/DartBot/events{/privacy}","received_events_url":"https://api.github.com/users/DartBot/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dart-lang/test/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/dart-lang/test/labels/Fixed","name":"Fixed","color":"ededed"},{"url":"https://api.github.com/repos/dart-lang/test/labels/Priority-Medium","name":"Priority-Medium","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-06-05T23:17:52Z","updated_at":"2015-06-05T23:17:53Z","closed_at":null,"body":"<a href=\"https://github.com/nex3\"><img src=\"https://avatars.githubusercontent.com/u/188?v=3\" align=\"left\" width=\"96\" height=\"96\"hspace=\"10\"></img></a> **Issue by [nex3](https://github.com/nex3)**\n_Originally opened as dart-lang/sdk#6389_\n\n----\n\nIf a test fails asynchronously, or at least in a Future that's expected to complete, it causes all sorts of havoc for future tests. Consider the following example:\n\n&nbsp;&nbsp;&nbsp;&nbsp;Future get async {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var completer = new Completer();\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;new Timer(0, (_) =&gt; completer.complete(null));\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return completer.future;\n&nbsp;&nbsp;&nbsp;&nbsp;}\n\n&nbsp;&nbsp;&nbsp;&nbsp;test('test 1', () {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;expect(async.transform((_) {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw 'error 1';\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}), completes);\n&nbsp;&nbsp;&nbsp;&nbsp;});\n\n&nbsp;&nbsp;&nbsp;&nbsp;test('test 2', () {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;expect(async.transform((_) {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw 'error 2';\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}), completes);\n&nbsp;&nbsp;&nbsp;&nbsp;});\n\nWhen run, only test 1 reports an error. Test 2's asynchronous code is apparently never run at all.\n\nConsider also the following code:\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setUp(() =&gt; print(&quot;setUp&quot;));\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tearDown(() =&gt; print(&quot;tearDown&quot;));\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;test('test 1', () {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;expect(async.transform((_) {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw 'error 1';\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}), completes);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;test('test 2', () {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print(&quot;in test 2 synchronously&quot;);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;expect(async.transform((_) {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print(&quot;in test 2 asynchronously&quot;);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}), completes);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;test('test 3', () {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print(&quot;in test 3 synchronously&quot;);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;expect(async.transform((_) {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print(&quot;in test 3 asynchronously&quot;);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}), completes);\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});\n\nThis prints:\n\n&nbsp;&nbsp;&nbsp;&nbsp;setUp\n&nbsp;&nbsp;&nbsp;&nbsp;tearDown\n&nbsp;&nbsp;&nbsp;&nbsp;setUp\n&nbsp;&nbsp;&nbsp;&nbsp;in test 2 synchronously\n&nbsp;&nbsp;&nbsp;&nbsp;tearDown\n&nbsp;&nbsp;&nbsp;&nbsp;setUp\n&nbsp;&nbsp;&nbsp;&nbsp;in test 3 synchronously\n&nbsp;&nbsp;&nbsp;&nbsp;in test 2 asynchronously\n&nbsp;&nbsp;&nbsp;&nbsp;in test 3 asynchronously\n&nbsp;&nbsp;&nbsp;&nbsp;tearDown\n\nNote that test 2's asynchronous callback isn't run until after its tearDown method has been called and after test 3's setUp method is called and test 3 has been run synchronously."},"comment":{"url":"https://api.github.com/repos/dart-lang/test/issues/comments/109478543","html_url":"https://github.com/dart-lang/test/issues/163#issuecomment-109478543","issue_url":"https://api.github.com/repos/dart-lang/test/issues/163","id":109478543,"user":{"login":"DartBot","id":8958862,"avatar_url":"https://avatars.githubusercontent.com/u/8958862?v=3","gravatar_id":"","url":"https://api.github.com/users/DartBot","html_url":"https://github.com/DartBot","followers_url":"https://api.github.com/users/DartBot/followers","following_url":"https://api.github.com/users/DartBot/following{/other_user}","gists_url":"https://api.github.com/users/DartBot/gists{/gist_id}","starred_url":"https://api.github.com/users/DartBot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DartBot/subscriptions","organizations_url":"https://api.github.com/users/DartBot/orgs","repos_url":"https://api.github.com/users/DartBot/repos","events_url":"https://api.github.com/users/DartBot/events{/privacy}","received_events_url":"https://api.github.com/users/DartBot/received_events","type":"User","site_admin":false},"created_at":"2015-06-05T23:17:53Z","updated_at":"2015-06-05T23:17:53Z","body":"<a href=\"https://github.com/kevmoo\"><img src=\"https://avatars.githubusercontent.com/u/17034?v=3\" align=\"left\" width=\"48\" height=\"48\"hspace=\"10\"></img></a> **Comment by [kevmoo](https://github.com/kevmoo)**\n\n----\n\n*Removed [Area-UnitTest](../labels/Area-UnitTest) label.*\n*Added [Area-Pkg](../labels/Area-Pkg) label.*\n"}}