我试图了解 Gauge 如何处理测试的并发执行以及它如何管理状态。但是,我不明白应该如何gauge_clear_state_level
工作。我在 Javascript 和 Typescript 中创建了两个小示例,对于这两个示例我都没有看到任何效果。
在我default.properties
的设置如下:
...
gauge_clear_state_level = scenario
...
这是我的测试规范:
# Example specification A
## Example scenario A1
* foo "A1"
* bar "A1"
* foo "A1"
## Example scenario A2
* bar "A2"
* foo "A2"
* bar "A2"
Typescript 中的实现如下所示:
import { Step } from "gauge-ts";
export default class StepImplementation {
private fooCounter: number = 0;
private barCounter: number = 0;
@Step("foo <x>")
public async foo(x: string) {
await delay(1000);
this.fooCounter++;
console.log("foo " + x + " (" + this.fooCounter + ")")
}
@Step("bar <x>")
public async bar(x: string) {
await delay(1000);
this.barCounter++;
console.log("bar " + x + " (" + this.barCounter + ")")
}
}
// https://stackoverflow.com/a/37764963
function delay(ms: number) {
return new Promise( resolve => setTimeout(resolve, ms) );
}
当我运行规范时,输出是:
Running tool: gauge.cmd run c:\....\specs\exampleA.spec --simple-console --hide-suggestion
"Windows support is not tested yet. There might be some issues."
# Example specification A
## Example scenario A1
foo A1 (1)
bar A1 (1)
foo A1 (2)
## Example scenario A2
bar A2 (2)
foo A2 (3)
bar A2 (3)
Successfully generated html-report to => c:\....\reports\html-report\index.html
Specifications: 1 executed 1 passed 0 failed 0 skipped
Scenarios: 2 executed 2 passed 0 failed 0 skipped
Total time taken: 6.424s
Success: Tests passed.
我所期望的是,在每种情况下都会重置两个计数器,但上面的输出表明情况并非如此。
任何想法或建议任何人?