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

Test scope left open if test injection fails #1

Closed
nlativy opened this issue Jan 20, 2015 · 0 comments
Closed

Test scope left open if test injection fails #1

nlativy opened this issue Jan 20, 2015 · 0 comments
Assignees
Labels

Comments

@nlativy
Copy link
Collaborator

nlativy commented Jan 20, 2015

We enter and exit test scope in TestEnvironment#beforeTest and TestEnvironment#afterTest respectively. The code in Acai which calls these methods looks like:

TestEnvironment testEnvironment = getOrCreateTestEnvironment(module);
testEnvironment.beforeSuiteIfNotAlreadyRun();
testEnvironment.beforeTest();
testEnvironment.inject(target);
try {
  statement.evaluate();
} finally {
  testEnvironment.afterTest();
}

If testEnvironment.inject(target) throws an exception we leave the scope open and all future tests fail with the exception:

java.lang.IllegalStateException: TestScope is already in progress.
    at com.google.common.base.Preconditions.checkState(Preconditions.java:177)
    at com.google.acai.TestScope.enter(TestScope.java:37)
    at com.google.acai.Acai$TestEnvironment.beforeTest(Acai.java:160)
    at com.google.acai.Acai$1.evaluate(Acai.java:78)

This also means, of course, that we fail to do any per-test tear-down as well in this case.

In fixing this issue another case to be aware of is that if a user defined @BeforeTest method fails currently this would also cause the TestScope to not be exited so simply moving testEnvironment.inject(target) into the try block will not make the code completely robust. We probably need to decouple the enter/exit scope from running @BeforeTest and @AfterTest methods.

@nlativy nlativy self-assigned this Jan 20, 2015
@nlativy nlativy added the bug label Jan 20, 2015
@nlativy nlativy changed the title Test scope left open in test injection fails Test scope left open if test injection fails Mar 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant