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
Currently each TestingService is instantiated once per environment. This means if you wish to do something with an object bound with a @TestScoped binding you need to use a Provider.
A common example might be a service that quits the webdriver instance started for an individual test:
classWebDriverQuitterimplementsTestingService {
@InjectProvider<WebDriver> webDriver;
@AfterTestvoidquitWebDriver() throwsException {
// Calling get on the Provider here returns the instance// for the test case which we are currently tearing down.webDriver.get().quit();
}
}
If we supported injecting each @BeforeTest, @AfterTest method then this could become:
injecting the correct instance for the current test scope.
While cute this adds a bit of complexity so we should consider if it's worth bloating the API for something that's already achievable anyway. Also the scope will not be test scope when running @BeforeSuite methods so we should be careful that doesn't cause confusion.
Also would users then want to inject test methods too? That doesn't add as much value since the scope is the same as when injecting the test object. It would mean objects used in one test case only could be injected there rather than being fields but in such cases maybe the user should be splitting into multiple test classes anyway. Worth considering if this inconsistency between test methods and test services would be confusing though if we only supported injecting the service methods.
The text was updated successfully, but these errors were encountered:
nlativy
changed the title
Consider support injecting methods in testing services
Consider supporting injecting methods of testing services
Mar 21, 2015
nlativy
changed the title
Consider supporting injecting methods of testing services
Support injecting methods of testing services
Mar 21, 2015
Currently each TestingService is instantiated once per environment. This means if you wish to do something with an object bound with a
@TestScoped
binding you need to use aProvider
.A common example might be a service that quits the webdriver instance started for an individual test:
If we supported injecting each
@BeforeTest
,@AfterTest
method then this could become:injecting the correct instance for the current test scope.
While cute this adds a bit of complexity so we should consider if it's worth bloating the API for something that's already achievable anyway. Also the scope will not be test scope when running
@BeforeSuite
methods so we should be careful that doesn't cause confusion.Also would users then want to inject test methods too? That doesn't add as much value since the scope is the same as when injecting the test object. It would mean objects used in one test case only could be injected there rather than being fields but in such cases maybe the user should be splitting into multiple test classes anyway. Worth considering if this inconsistency between test methods and test services would be confusing though if we only supported injecting the service methods.
The text was updated successfully, but these errors were encountered: