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

refactor: introduce adapter pattern for test results #493

Merged
merged 3 commits into from
Sep 6, 2023

Conversation

shadowusr
Copy link
Member

@shadowusr shadowusr commented Sep 5, 2023

What's done?

  • Defined ReporterTestResult as a single interface to interact with across all of the html-reporter code. Adjusted TestAdapter accordingly, renamed it to HermioneTestAdapter and got rid of unnecessary field/methods
  • Got rid of SuiteAdapter by partially merging it into TestAdapter and partially moving the logic to helpers
  • Fixed a bug that caused duplicating skipped tests records in sqlite db
  • Refactored types — got rid of code duplication by importing what was possible from hermione package. See fix: export TestResult and Suite types testplane#786

Why?

  • These changes make easier both reasoning about the existing code and supporting other test frameworks besides hermione — you only need to implement a corresponding TestAdapter class

Copy link
Member

@DudaGod DudaGod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

lib/image-handler.ts Show resolved Hide resolved
lib/report-builder/static.ts Outdated Show resolved Hide resolved
@@ -83,7 +83,6 @@
"qs": "^6.9.1",
"signal-exit": "^3.0.2",
"tmp": "^0.1.0",
"urijs": "^1.18.12",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а разве из package-lock.json он не должен был тоже пропасть?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да, должен, просто package-lock я обычно обновляю перед влитием. Обязательно обновлю. Ну и не хотел пугать большим диффом в PR )

lib/gui/tool-runner/index.js Outdated Show resolved Hide resolved
@@ -77,11 +81,12 @@ module.exports = (hermione, reportBuilder, client, reportPath) => {

hermione.on(hermione.events.TEST_FAIL, (testResult) => {
queue.add(async () => {
const formattedResult = reportBuilder.format(testResult, hermione.events.TEST_FAIL);
const status = hasDiff(testResult.assertViewResults) ? TestStatus.FAIL : TestStatus.ERROR;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я понимаю, что эта логика была и до этого PR-а, но почему мы выставляем fail именно при наличии диффа? чем это отличается от обычного провалившегося ассерта?

//cc @DudaGod

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я сам недавно задавался этим вопросом когда интеграцию pwt с testcop пилил. Сходу не помню почему так было сделано.


return {name, suitePath, browserId};
get url(): string | undefined {
return this._testResult.meta.url as string | undefined;
}

get multipleTabs(): boolean {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

кажется, эта фигня уже никому не нужна

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Согласен. Но на это есть много завязок в html-reporter, многое может сломаться, если сейчас выгасить. Мне кажется это лучше делать в отдельном PR

lib/test-adapter/index.ts Outdated Show resolved Hide resolved
@shadowusr shadowusr force-pushed the users/shadowusr/HERMIONE-1003.refactoring-part-2 branch from 9db24c7 to e10d2fe Compare September 6, 2023 20:09
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

дифф большой из-за добавления pwt в devDependencies.

@shadowusr shadowusr force-pushed the users/shadowusr/HERMIONE-1003.refactoring-part-2 branch from e10d2fe to a4a6b9b Compare September 6, 2023 20:23
@shadowusr shadowusr force-pushed the users/shadowusr/HERMIONE-1003.refactoring-part-2 branch from a4a6b9b to a679d08 Compare September 6, 2023 20:27
@shadowusr shadowusr merged commit 517ab15 into master Sep 6, 2023
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants