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

(TestNG) TextReport should be Thread-safe #364

Closed
asolntsev opened this Issue Jul 31, 2016 · 1 comment

Comments

Projects
None yet
1 participant
@asolntsev
Member

asolntsev commented Jul 31, 2016

Now TextReport listener is not thread-safe.

When I run a set of tests in 2+ threads in parallel, some tests have an empty sample text report despite tests passed. In other words, console report table is empty for some tests.
Issue never happens when I run tests in a single thread sequentially, console report tables are filled in for all tests.

@asolntsev asolntsev added this to the 3.8 milestone Jul 31, 2016

@asolntsev asolntsev self-assigned this Jul 31, 2016

@asolntsev

This comment has been minimized.

Show comment
Hide comment
@asolntsev

asolntsev Jul 31, 2016

Member

I found that there is really an issue with TextReport. It works differently with JUnit and TestNG.

  • In JUnit, TextReport is declared as a Rule:
@Rule
public TestRule report = new TextReport();

JUnit creates a new TextReport instance before every test.

  • In TestNG, TextReport is declared as a listener:
@Listeners(TextReport.class)

TestNG creates only one instance of listener and re-uses it for all the tests. That's why we have a concurrency issue.

Member

asolntsev commented Jul 31, 2016

I found that there is really an issue with TextReport. It works differently with JUnit and TestNG.

  • In JUnit, TextReport is declared as a Rule:
@Rule
public TestRule report = new TextReport();

JUnit creates a new TextReport instance before every test.

  • In TestNG, TextReport is declared as a listener:
@Listeners(TextReport.class)

TestNG creates only one instance of listener and re-uses it for all the tests. That's why we have a concurrency issue.

@asolntsev asolntsev closed this in 09f1e16 Aug 3, 2016

asolntsev added a commit that referenced this issue Aug 3, 2016

Fixes #364 #303 class SoftAsserts is now thread-safe
it doesn't hold a single instance of ErrorsCollector, but creates a new one for every test

asolntsev added a commit that referenced this issue Aug 4, 2016

BorisOsipov added a commit to BorisOsipov/selenide that referenced this issue Nov 23, 2016

Fixes #364 #303 class SimpleReport is now thread-safe
it doesn't hold a single instance of EventsCollector, but creates a new one for every thread

BorisOsipov added a commit to BorisOsipov/selenide that referenced this issue Nov 23, 2016

Fixes #364 #303 class SoftAsserts is now thread-safe
it doesn't hold a single instance of ErrorsCollector, but creates a new one for every test

BorisOsipov added a commit to BorisOsipov/selenide that referenced this issue Nov 23, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment