Tuesday 15 May 2012

unit testing - How can I make test inside a then statement in Dart -


I want to do some tests on some functions, but I need to execute all the tests after the end of the future.

An example of how to develop my problem, here's what I would like to:

  registerToServer (contentOfRequest). Then ((ID) {test ('test function 1', () {function1 (id, contentOfRequest). Then (expected sign ((wal)) {hope (wal, whatIExpect);}));}); Exam ('test function 2', () {Function2 (id, contentOfRequest). Then (expectAsync (val) {hope (val, whatIExpect);}));}): ...};  

I have tried with an alternative solution, but nothing changes for this:

 < Code> String ID; RegisterToServer (contentOfRequest) then ((SID) {id = sid;}). Then ((_) {test ( 'test function1', ()} {function1 (id, contentOfRequest). Then (expectAsync ((val) {hope (val, whatIExpect);}));}); test ( 'test Function2 ', () {function2 (id, contentOfRequest). Then (expectAsync (val) {expect (val, whatIExpect);}));}): ...};  

And if possible, the test will be arranged in that form because I want a description of all the tests.

The Stacktrace is something like this:

Unchecked exception: Unwanted error: Bad status: Test is running when not allowed. Stack trace: # 0 _requireNotRunning (package: unittest / unittest.dart: 430: 3) # 1 test (package: unittest / unittest.dart: 100: 21) # 2 main. & Lt; Anonymous Closed & gt; (File: ///.../server_test.dart: 260: 11) # 3 _RootZone.runUnary (DART: async / zone.dart: 1155) # 4 _Future._propagateToListeners.handleValueCallback (DART: async / future_impl.dart: 484) # 5 _Future._propagateToListeners (DART: async / future_impl.dart: 567) # 6 _Future._completeWithValue (DART: async / future_impl.dart: 358) # 7 _Future._asyncComplete & LT; Anonymous shutdown & gt; # 8 _asyncRunCallbackLoop (Dart: Async / Future_IMApple Dart: 412) # 8 _asyncRunCallbackLoop (Dart: Async / Schedule_Michrotusque Dart: 41) # 9_Assistrict Callback (Dart: Async / Schedule_Michrotusche Dart: 48) # 10 _runPendingImmediateCallback (Dart: Isolation-Patches / Isolation_patch). Dart: 84) # 11 _ start isolate (dart: isolation-patch / isolate_patch dart: 244) # 12_stant mine islet. & Lt; Anonymous Closed & gt; (DART: different patches / isolate_patch.dart: 192) # 13 _RawReceivePortImpl._handleMessage (DART: different patches / isolate_patch.dart: 130) # 0 _rootHandleUncaughtError & LT; Anonymous shutdown & gt; (Dart: ASNSC / Zone Deert: 886) # 1_ConnectCallback Loop (Dart: Async / Schedule_Michrotusque Dart: 41) # 2_Synchronous Callback (Dart: Async / Schedule_Michrotusk Dart: 48) # 3 _runPendingImmediateCallback (Dart: Isolation-Patches / Isolate- Patch dart: 84) # 4 _ start isolate (dart: isolation-patch / isolate_patched dart: 244) # 5 _stant mine isylate. & Lt; Anonymous Closed & gt; (DART: different patches / isolate_patch.dart: 192) # 6 _RawReceivePortImpl._handleMessage (DART: different patches / isolate_patch.dart: 130)

I think it is not supported to wrap other tasks such as trials like you did here

  ( 

test ('test function1', () {

You can use setUp () test

  to prepare for Main () {group ('xxx', () {Setup (() {return registerToServer (contentOfRequest);}}}}}}}}}}}}}}  

It is that there is currently no way to set up for a set of tests. setUp () and tear () are called before / after each single test For an add comment (+1 or similar)

When the use of async calls is used under set up / teardown / test, always returns the future. The test framework recognizes that the future should be taken. Taya is expected to wait until the end before the end of the future. In this way you do not have to face with the expectedSink or similar tool.


No comments:

Post a Comment