You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copied from mscharhag/oleaster#16
The default JUnit runner isolate tests in a way that every test gets executed with a new test-case instance. This ensures a fresh fixture instance for each test, even if the developer uses an implicit setup shortcut.
It seems to me that Oleaster tests work always with the same fixture in such a case. This is because the test-case instance is reused for all test runs (see snippet below for a better understanding of the use-case).
This behavior might lead to problems which are difficult to understand. Although I am not a particular friend of this setup practice, I doubt that people will follow a do-not-use-this-kind-of-implicit-setup convention. Maybe it would be better to ensure this kind of isolation as JUnit does by default.
mscharhag said:
Thanks for bringing this up. You are right, all Oleaster tests use the same test instance at the moment.
The problem here is that lambda expressions are bound to the scope of the surrounding object. In order to run specs in complete isolation
a new test instance is required for each spec
the code of all surrounding suites needs to be executed for the new test instance
So far I think this would be a good thing. However, I need to think a bit more about the consequences.
I will look into this.
Hi marioluan,
thanks for your feedback.
The current behavior is this:
publicclassMyTest {{
// executed once, before the first test runsdescribe("suite", () -> {
// executed once, before the first test runsbeforeEach(() -> {
// executed before each test
});
it("test", () -> {
// executed once
});
});
}}
When creating a new instance of the test class for each test, all the surrounding describe() blocks need to be executed again.
So the new behavior would be:
publicclassMyTest {{
// executed before each testdescribe("suite", () -> {
// executed before each testbeforeEach(() -> {
// executed before each test
});
it("test", () -> {
// executed once
});
});
}}
This means:
using beforeEach() should not be necessary in most cases. Instead the surrounding describe() block can be used. I think this is ok, but it is different to Jasmine's behaviour.
There is no way to run initialization code once (before the first test case). I think the best solution to this is to support JUnits @BeforeClass and @afterclass annotations in Oleaster tests.
It breaks compatibility with test written for older Oleaster versions. While I don't like this one, I think it is ok. Oleaster is still in an early version.
Feel free to share your opinions.
Copied from mscharhag/oleaster#16
The default JUnit runner isolate tests in a way that every test gets executed with a new test-case instance. This ensures a fresh fixture instance for each test, even if the developer uses an implicit setup shortcut.
It seems to me that Oleaster tests work always with the same fixture in such a case. This is because the test-case instance is reused for all test runs (see snippet below for a better understanding of the use-case).
This behavior might lead to problems which are difficult to understand. Although I am not a particular friend of this setup practice, I doubt that people will follow a do-not-use-this-kind-of-implicit-setup convention. Maybe it would be better to ensure this kind of isolation as JUnit does by default.
The text was updated successfully, but these errors were encountered: