Asynchronous-Testing
You can tag a bundle component declaration with the boolean asyncAll annotation and TestBox will execute all specs in separate threads for you concurrently.
1
component displayName="TestBox xUnit suite" skip="testEnv" asyncAll=true{
2
3
function setup(){
4
application.wirebox = new coldbox.system.ioc.Injector();
5
structClear( request );
6
}
7
8
function teardown(){
9
structDelete( application, "wirebox" );
10
structClear( request );
11
}
12
13
function testThrows() skip="true"{
14
$assert.throws(function(){
15
var hello = application.wirebox.getInstance( "myINvalidService" ).run();
16
});
17
}
18
19
function testNotThrows(){
20
$assert.notThrows(function(){
21
var hello = application.wirebox.getInstance( "MyValidService" ).run();;
22
});
23
}
24
25
private boolean function testEnv(){
26
return ( structKeyExists( request, "env") && request.env == "stg" ? true : false );
27
}
28
29
}
Copied!
Caution Once you delve into the asynchronous world you will have to make sure your tests are also thread safe (var-scoped) and provide any necessary locking.
Last modified 3yr ago
Copy link