Skip to content

Commit dec7bc3

Browse files
committed
integration test: add error validation
1 parent ca23287 commit dec7bc3

13 files changed

+145
-12
lines changed

test/integration/modules/integration-test/test-case/test-case-result.js

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,40 @@ class TestCaseResult {
4141
deleteTestCaseResultReady = this.#deleteTestCaseResult();
4242
}
4343
deleteTestCaseResultReady.then(() => {
44-
if (this.#testData.result == "PASSED") {
45-
return resolve(this.#createTestCaseResultPassed());
46-
} else if(this.#testData.result == "WARNING") {
47-
return resolve(this.#createTestCaseResultWarning());
48-
} else if(this.#testData.result == "FAILED") {
49-
return resolve(this.#createTestCaseResultFailed());
44+
45+
if (this.#testCaseObj.testCase in this.#testCaseObj.testCasesConfig.tests &&
46+
"err" in this.#testCaseObj.testCasesConfig.tests[this.#testCaseObj.testCase]) {
47+
let err = this.#testCaseObj.testCasesConfig.tests[this.#testCaseObj.testCase]["err"];
48+
if (this.#testData.result === "ERROR") {
49+
if(this.#testData.description.includes(err)) {
50+
return resolve(this.#createTestCaseResultPassed(err));
51+
} else {
52+
return resolve(this.#createTestCaseResultError());
53+
}
54+
} else {
55+
this.#testData.result = "ERROR";
56+
this.#testData.description = "did not occur " + err;
57+
return resolve(this.#createTestCaseResultError());
58+
}
5059
} else {
51-
return resolve(this.#createTestCaseResultError());
60+
if (this.#testData.result === "PASSED") {
61+
return resolve(this.#createTestCaseResultPassed(this.#testData.hash));
62+
} else if(this.#testData.result === "WARNING") {
63+
return resolve(this.#createTestCaseResultWarning());
64+
} else if(this.#testData.result === "FAILED") {
65+
return resolve(this.#createTestCaseResultFailed());
66+
} else {
67+
return resolve(this.#createTestCaseResultError());
68+
}
5269
}
5370
});
5471
});
5572
}
5673

5774

58-
#createTestCaseResultPassed() {
75+
#createTestCaseResultPassed(msg) {
5976
this.#testCaseObj.testSuiteResults.PASSED.push(this.#testCaseObj.testCase);
60-
this.#cnsl.log(("[ " + this.#testData.result.padEnd(this.#cnsl.getTestStatusPad(), " ") + " ] ").success + "[ " + String(++this.#testCaseObj.testSuiteResults.FINISHED).padEnd(this.#cnsl.getTestNumberPad(), " ") + " ] " + "[ " + this.#testData.hash + " ] " + path.relative(TestEnv.getTestSuitePath(), path.join(TestEnv.getWorkspacePath(), this.#testCaseObj.testCase)));
77+
this.#cnsl.log(("[ " + "PASSED".padEnd(this.#cnsl.getTestStatusPad(), " ") + " ] ").success + "[ " + String(++this.#testCaseObj.testSuiteResults.FINISHED).padEnd(this.#cnsl.getTestNumberPad(), " ") + " ] " + "[ " + msg + " ] " + path.relative(TestEnv.getTestSuitePath(), path.join(TestEnv.getWorkspacePath(), this.#testCaseObj.testCase)));
6178
if (this.#testCaseObj.createImages === "ALL") {
6279
this.#createImage(this.#testData, '-1new');
6380
}
@@ -66,7 +83,7 @@ class TestCaseResult {
6683

6784
#createTestCaseResultWarning() {
6885
this.#testCaseObj.testSuiteResults.WARNING.push(this.#testCaseObj.testCase);
69-
this.#cnsl.log(("[ " + this.#testData.result.padEnd(this.#cnsl.getTestStatusPad(), " ") + " ] " + "[ " + String(++this.#testCaseObj.testSuiteResults.FINISHED).padEnd(this.#cnsl.getTestNumberPad(), " ") + " ] " + "[ " + this.#testData.description + " ] ").warn + path.relative(TestEnv.getTestSuitePath(), path.join(TestEnv.getWorkspacePath(), this.#testCaseObj.testCase)));
86+
this.#cnsl.log(("[ " + "WARNING".padEnd(this.#cnsl.getTestStatusPad(), " ") + " ] " + "[ " + String(++this.#testCaseObj.testSuiteResults.FINISHED).padEnd(this.#cnsl.getTestNumberPad(), " ") + " ] " + "[ " + this.#testData.description + " ] ").warn + path.relative(TestEnv.getTestSuitePath(), path.join(TestEnv.getWorkspacePath(), this.#testCaseObj.testCase)));
7087
if (this.#testCaseObj.createImages !== "DISABLED") {
7188
this.#createImage(this.#testData, '-1new');
7289
}
@@ -108,7 +125,7 @@ class TestCaseResult {
108125

109126
#createTestCaseResultError() {
110127
this.#testCaseObj.testSuiteResults.FAILED.push(this.#testCaseObj.testCase);
111-
this.#createTestCaseResultErrorMsg();
128+
this.#createTestCaseResultErrorMsg();
112129
}
113130

114131

test/integration/modules/integration-test/test-case/test-case.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class TestCase {
3838
return new Promise((resolve, reject) => {
3939
let refHash = [];
4040
let animStep = { step: testCaseObj.animStep, default: true };
41+
let errMsg;
4142
if (testCaseObj.testCase in testCaseObj.testCasesConfig.tests) {
4243
if ("animstep" in testCaseObj.testCasesConfig.tests[testCaseObj.testCase]) {
4344
animStep.step = testCaseObj.testCasesConfig.tests[testCaseObj.testCase]["animstep"].replace("%", "");
@@ -46,6 +47,9 @@ class TestCase {
4647
if ("refs" in testCaseObj.testCasesConfig.tests[testCaseObj.testCase]) {
4748
refHash = testCaseObj.testCasesConfig.tests[testCaseObj.testCase]["refs"];
4849
}
50+
if ("err" in testCaseObj.testCasesConfig.tests[testCaseObj.testCase]) {
51+
errMsg = testCaseObj.testCasesConfig.tests[testCaseObj.testCase]["err"];
52+
}
4953
}
5054
if (vizzuUrl.startsWith("/")) {
5155
vizzuUrl = "/" + path.relative(TestEnv.getWorkspacePath(), vizzuUrl);
@@ -64,6 +68,9 @@ class TestCase {
6468
if (!animStep.default) {
6569
testData["animstep"] = animStep.step;
6670
}
71+
if (errMsg) {
72+
testData["err"] = errMsg;
73+
}
6774
return resolve(testData);
6875
})
6976
}).catch(err => {

test/integration/modules/integration-test/test-case/test-cases-config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ class TestCasesConfig {
102102
},
103103
animstep: {
104104
type: "string"
105+
},
106+
err: {
107+
type: "string"
105108
}
106109
},
107110
additionalProperties: false
@@ -149,6 +152,9 @@ class TestCasesConfig {
149152
},
150153
animstep: {
151154
type: "string"
155+
},
156+
err: {
157+
type: "string"
152158
}
153159
},
154160
additionalProperties: false
@@ -169,6 +175,9 @@ class TestCasesConfig {
169175
},
170176
animstep: {
171177
type: "string"
178+
},
179+
err: {
180+
type: "string"
172181
}
173182
},
174183
additionalProperties: false

test/integration/modules/integration-test/test-suite-result.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ class TestSuiteResult {
7676
if(this.#testSuiteResults.RESULTS[key]["animstep"]) {
7777
testData["animstep"] = this.#testSuiteResults.RESULTS[key]["animstep"] + "%";
7878
}
79-
testData["refs"] = [this.#testSuiteResults.RESULTS[key]['hash']]
79+
if (this.#testSuiteResults.RESULTS[key]["err"]) {
80+
testData["err"] = this.#testSuiteResults.RESULTS[key]['err'];
81+
} else {
82+
testData["refs"] = [this.#testSuiteResults.RESULTS[key]['hash']];
83+
}
8084
testCasesConfig[suite].test[path.relative(suite, key)] = testData;
8185
}
8286
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Chart from "/test/integration/test_options/style/plot/backgroundColor/chart.js";
2+
3+
4+
const testSteps = [
5+
Chart.static("#ABCDEG")
6+
]
7+
8+
9+
export default testSteps
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Chart from "/test/integration/test_options/style/plot/backgroundColor/chart.js";
2+
3+
4+
const testSteps = [
5+
Chart.static("#00000!")
6+
]
7+
8+
9+
export default testSteps
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Chart from "/test/integration/test_options/style/plot/backgroundColor/chart.js";
2+
3+
4+
const testSteps = [
5+
Chart.static("#ABCDEFFG")
6+
]
7+
8+
9+
export default testSteps
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Chart from "/test/integration/test_options/style/plot/backgroundColor/chart.js";
2+
3+
4+
const testSteps = [
5+
Chart.static("#")
6+
]
7+
8+
9+
export default testSteps
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Chart from "/test/integration/test_options/style/plot/backgroundColor/chart.js";
2+
3+
4+
const testSteps = [
5+
Chart.static("#000")
6+
]
7+
8+
9+
export default testSteps
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Chart from "/test/integration/test_options/style/plot/backgroundColor/chart.js";
2+
3+
4+
const testSteps = [
5+
Chart.static("#00000")
6+
]
7+
8+
9+
export default testSteps

0 commit comments

Comments
 (0)