diff --git a/bb-core/pom.xml b/bb-core/pom.xml index fb1ae366..4530021c 100644 --- a/bb-core/pom.xml +++ b/bb-core/pom.xml @@ -97,6 +97,10 @@ limitations under the License. + + org.junit.jupiter + junit-jupiter-api + org.junit.jupiter junit-jupiter-params diff --git a/bb-core/src/main/java/com/cognifide/qa/bb/wait/BobcatWait.java b/bb-core/src/main/java/com/cognifide/qa/bb/wait/BobcatWait.java index 40f7e9c0..783ab324 100644 --- a/bb-core/src/main/java/com/cognifide/qa/bb/wait/BobcatWait.java +++ b/bb-core/src/main/java/com/cognifide/qa/bb/wait/BobcatWait.java @@ -35,6 +35,7 @@ import com.cognifide.qa.bb.guice.ThreadScoped; import com.google.inject.Inject; +import com.google.inject.Provider; /** * This is the go-to solution for handling dynamic elements with Bobcat. @@ -49,12 +50,8 @@ public class BobcatWait { private List> ignoredExceptions = new ArrayList<>(); - private WebDriver webDriver; - @Inject - public BobcatWait(WebDriver webDriver) { - this.webDriver = webDriver; - } + private Provider webDriverProvider; /** * Allows to customize the timings (explicit & implicit timeout + polling time). @@ -125,20 +122,22 @@ public boolean isConditionMet(final ExpectedCondition condition) { * Sets implicit timeout to {@value Timings#NEAR_ZERO} milliseconds. */ protected void setImplicitTimeoutToNearZero() { - webDriver.manage().timeouts().implicitlyWait(Timings.NEAR_ZERO, TimeUnit.SECONDS); + webDriverProvider.get().manage().timeouts().implicitlyWait(Timings.NEAR_ZERO, TimeUnit.SECONDS); } /** * Restores implicit timeout to the value defined in the {@link Timings} instance. */ protected void restoreImplicitTimeout() { - webDriver.manage().timeouts().implicitlyWait(timings.getImplicitTimeout(), TimeUnit.SECONDS); + webDriverProvider.get().manage().timeouts() + .implicitlyWait(timings.getImplicitTimeout(), TimeUnit.SECONDS); } /** * @return an instance of {@link WebDriverWait} based on the provided {@link Timings} */ protected WebDriverWait getWebDriverWait() { - return new WebDriverWait(webDriver, timings.getExplicitTimeout(), timings.getPollingInterval()); + return new WebDriverWait(webDriverProvider.get(), timings.getExplicitTimeout(), + timings.getPollingInterval()); } } diff --git a/bb-core/src/test/java/com/cognifide/qa/bb/wait/BobcatWaitTest.java b/bb-core/src/test/java/com/cognifide/qa/bb/wait/BobcatWaitTest.java index 6cb04cb7..2fac73f3 100644 --- a/bb-core/src/test/java/com/cognifide/qa/bb/wait/BobcatWaitTest.java +++ b/bb-core/src/test/java/com/cognifide/qa/bb/wait/BobcatWaitTest.java @@ -28,15 +28,21 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InOrder; +import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.openqa.selenium.TimeoutException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.support.ui.ExpectedCondition; +import com.cognifide.qa.bb.provider.selenium.webdriver.WebDriverProvider; + @ExtendWith(MockitoExtension.class) public class BobcatWaitTest { + @Mock + private WebDriverProvider webDriverProvider; + @Mock private WebDriver webDriver; @@ -49,6 +55,7 @@ public class BobcatWaitTest { @Mock private ExpectedCondition condition; + @InjectMocks private BobcatWait tested; @BeforeEach @@ -56,7 +63,7 @@ public void setup() { when(webDriver.manage()).thenReturn(options); when(options.timeouts()).thenReturn(timeouts); when(timeouts.implicitlyWait(anyLong(), any())).thenReturn(timeouts); - tested = new BobcatWait(webDriver); + when(webDriverProvider.get()).thenReturn(webDriver); } @Test diff --git a/bb-email/pom.xml b/bb-email/pom.xml index a67df694..6355b9c4 100644 --- a/bb-email/pom.xml +++ b/bb-email/pom.xml @@ -60,16 +60,21 @@ mockito-core test - - - - - - - - - - + + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.jupiter + junit-jupiter-engine + test + + + org.junit.jupiter + junit-jupiter-params + test + org.hamcrest hamcrest-core diff --git a/bb-integration-tests/pom.xml b/bb-integration-tests/pom.xml index 2b147dd1..e1015a1b 100644 --- a/bb-integration-tests/pom.xml +++ b/bb-integration-tests/pom.xml @@ -97,6 +97,13 @@ org.apache.maven.plugins maven-surefire-plugin + + + + junit.jupiter.extensions.autodetection.enabled = true + + + diff --git a/bb-integration-tests/src/test/java/com/cognifide/qa/bb/core/config/YamlConfigTest.java b/bb-integration-tests/src/test/java/com/cognifide/qa/bb/core/config/YamlConfigTest.java index 04351784..5622ef5c 100644 --- a/bb-integration-tests/src/test/java/com/cognifide/qa/bb/core/config/YamlConfigTest.java +++ b/bb-integration-tests/src/test/java/com/cognifide/qa/bb/core/config/YamlConfigTest.java @@ -34,11 +34,6 @@ public class YamlConfigTest { - @BeforeEach - public void cleanProperties() { - System.setProperties(new Properties()); - } - @Test public void additionalContextsShouldBeLoadedWhenSelectedInConfig() { Properties properties = getInjector().getInstance(Properties.class); diff --git a/bb-junit5/pom.xml b/bb-junit5/pom.xml index 9ae9099c..f856b1d4 100644 --- a/bb-junit5/pom.xml +++ b/bb-junit5/pom.xml @@ -43,11 +43,6 @@ junit-jupiter-api - - org.junit.platform - junit-platform-commons - - com.google.inject guice diff --git a/pom.xml b/pom.xml index 3ec12100..20c39467 100644 --- a/pom.xml +++ b/pom.xml @@ -18,9 +18,7 @@ See the License for the specific language governing permissions and limitations under the License. #L% --> - + 4.0.0 com.cognifide.qa.bb @@ -30,8 +28,7 @@ limitations under the License. Bobcat Bobcat is an automated testing framework for functional testing of web - applications. - + applications. https://github.com/cognifide/bobcat 2016 @@ -88,11 +85,15 @@ limitations under the License. UTF-8 + 1.8 + ${maven.compiler.source} + 0.8.2 3.14.0 4.2.0 3.0.2 1.2.3 + 5.3.1 @@ -214,22 +215,17 @@ limitations under the License. org.junit.jupiter junit-jupiter-api - 5.3.1 + ${junit.jupiter.version} org.junit.jupiter junit-jupiter-params - 5.3.1 + ${junit.jupiter.version} org.junit.jupiter junit-jupiter-engine - 5.3.1 - - - org.junit.platform - junit-platform-commons - 1.2.0 + ${junit.jupiter.version} org.mockito @@ -265,12 +261,6 @@ limitations under the License. greenmail 1.5.8 test - - - - - - @@ -319,17 +309,6 @@ limitations under the License. - - org.apache.maven.plugins - maven-compiler-plugin - 3.3 - - true - 1.8 - 1.8 - 1.8 - - org.codehaus.mojo properties-maven-plugin @@ -477,6 +456,10 @@ limitations under the License. + + org.apache.maven.plugins + maven-surefire-plugin +