(TestNG) TextReport should be Thread-safe #364

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

Projects

None yet

1 participant

@asolntsev
Member

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
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.

@asolntsev asolntsev added a commit that closed this issue Aug 3, 2016
@asolntsev asolntsev 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
09f1e16
@asolntsev asolntsev closed this in 09f1e16 Aug 3, 2016
@asolntsev asolntsev added a commit that referenced this issue Aug 3, 2016
@asolntsev asolntsev 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
566022e
@asolntsev asolntsev added a commit that referenced this issue Aug 4, 2016
@asolntsev asolntsev Fixes #364 #303 JUnit implementation of SoftAsserts uses the same pat…
…tern as TestNG's one.
07e79bf
@BorisOsipov BorisOsipov added a commit to BorisOsipov/selenide that referenced this issue Nov 23, 2016
@asolntsev @BorisOsipov asolntsev + BorisOsipov 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
b4064b4
@BorisOsipov BorisOsipov added a commit to BorisOsipov/selenide that referenced this issue Nov 23, 2016
@asolntsev @BorisOsipov asolntsev + BorisOsipov 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
d58b6ee
@BorisOsipov BorisOsipov added a commit to BorisOsipov/selenide that referenced this issue Nov 23, 2016
@asolntsev @BorisOsipov asolntsev + BorisOsipov Fixes #364 #303 JUnit implementation of SoftAsserts uses the same pat…
…tern as TestNG's one.
994fbd1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment