Forum Discussion
- KSQianContributor
HKosova's approach is very TestComplete-y but I am more partial towards Robert's approach.
As projects get bigger you have to consider how easy it would be to wire new test cases or change the logic of what test cases you skip. Personally, its easier to change in code than to maintain it within the TestComplete workspace. Only change I'd make is to make the logic entirely in 'runAll' so its less obscure without tracing through multiple functions to determine the flow.
function runAll() {
if (testA() ) {
testB()
}
testC()
}
----
function testA() {
return pass?
}
function testB() {
return pass?
}
function testC() {
return pass?
}
- HKosova
Alumni
In the general case, given test items A and B, to skip B if A fails you need to:
- Make B a child item of A.
- For A, set "Stop on error" and "Stop on exception" to "Test Item".
- Unselect project properties "Stop on error" and "Error dialog".
This way if A fails B will be skipped.
For example, if your app crashes at the end of Test2 so that Test2 itself fails, you can use:
Test2 Stop on error = Test Item, Stop on exception = Test Item
┠ Test3
┖ Test4
Send EmailIf it crashes at the beginning of Test3:
Test2
Test3 Stop on error = Test Item, Stop on exception = Test Item
┖ Test4
Send Email - tristaanogreEsteemed Contributor
Yep, it's possible. But you need to do configurations, you need error checking within the tests, etc. This item was addressed sometime back. Here's a bit of code I wrote to demonstrate:
function TestA(isError) { try { if (isError) { throw new Error('Got an error in Test A'); } else { Log.Message('No error in Test A'); TestB(); } } catch (e) { Log.Error('rasied an error: ' + e.message, e.stack); } } function TestB() { Log.Message('Ran test B'); } function TestC(isError) { try { if (isError) { throw new Error('Got an error in Test C'); } else { Log.Message('No error in Test C'); TestD(); } } catch (e) { Log.Error('rasied an error: ' + e.message, e.stack); } } function TestD() { Log.Message('Ran test D'); } function RunAll() { TestA(true); TestC(false); }
I then configured my test items like so...
This is just one way. There are other ways with writing more complicated code, but, essentially, you'll want to do something similar.