Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow to override test & step timestamp #192

Merged
merged 2 commits into from
Jul 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/allure-js-commons/src/AllureGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export class AllureGroup {
return group;
}

startTest(name?: string): AllureTest {
const test = new AllureTest(this.runtime);
startTest(name?: string, start?: number): AllureTest {
const test = new AllureTest(this.runtime, start);
this.testResultContainer.children.push(test.uuid);
test.name = name || "Unnamed";
return test;
Expand Down
8 changes: 4 additions & 4 deletions packages/allure-js-commons/src/AllureTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import { AllureRuntime } from "./AllureRuntime";
export class AllureTest extends ExecutableItemWrapper {
private readonly testResult: TestResult;

constructor(private readonly runtime: AllureRuntime) {
constructor(private readonly runtime: AllureRuntime, start: number = Date.now()) {
super(testResult());
this.testResult = this.wrappedItem as TestResult;
this.testResult.start = Date.now();
this.testResult.start = start;
}

endTest(): void {
this.testResult.stop = Date.now();
endTest(stop: number = Date.now()): void {
this.testResult.stop = stop;
this.runtime.writeResult(this.testResult);
// TODO: test that child steps ended
}
Expand Down
12 changes: 6 additions & 6 deletions packages/allure-js-commons/src/ExecutableItemWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ export class ExecutableItemWrapper {
this.info.attachments.push({ name, type, source: fileName });
}

public startStep(name: string): AllureStep {
public startStep(name: string, start?: number): AllureStep {
const result = stepResult();
this.info.steps.push(result);

const allureStep = new AllureStep(result);
const allureStep = new AllureStep(result, start);
allureStep.name = name;
return allureStep;
}
Expand Down Expand Up @@ -113,13 +113,13 @@ export class ExecutableItemWrapper {

// This class is here because of circular dependency with ExecutableItemWrapper
export class AllureStep extends ExecutableItemWrapper {
constructor(private readonly stepResult: StepResult) {
constructor(private readonly stepResult: StepResult, start: number = Date.now()) {
super(stepResult);
this.stepResult.start = Date.now();
this.stepResult.start = start;
}

endStep() {
this.stepResult.stop = Date.now();
endStep(stop: number = Date.now()) {
this.stepResult.stop = stop;
// TODO: test that child steps ended
}
}