Asynchronous Testing
As you can see from our arguments for a test suite, you can pass an asyncAll argument to the describe() blocks that will allow TestBox to execute all specs in separate threads for you concurrently.
1
describe(title="A spec (with setup and tear-down)", asyncAll=true, body=function() {
2
3
beforeEach(function() {
4
coldbox = 22;
5
application.wirebox = new coldbox.system.ioc.Injector();
6
});
7
8
afterEach(function() {
9
coldbox = 0;
10
structDelete( application, "wirebox" );
11
});
12
13
it("is just a function, so it can contain any code", function() {
14
expect( coldbox ).toBe( 22 );
15
});
16
17
it("can have more than one expectation and talk to scopes", function() {
18
expect( coldbox ).toBe( 22 );
19
expect( application.wirebox.getInstance( 'MyService' ) ).toBeComponent();
20
});
21
});
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.
Copy link
Edit on GitHub