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

🐛 Fix firefox integration tests #20

Merged
merged 2 commits into from
May 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Features:
```shell script
$ mvn archetype:generate -DarchetypeGroupId=com.github.sergiomartins8 \
-DarchetypeArtifactId=ui-automation-bootstrap \
-DarchetypeVersion=1.0.0 \
-DarchetypeVersion=1.1.0 \
-DgroupId=awesome.group.id \
-DartifactId=awesome-template \
-Dcheckstyle=true \
Expand Down
7 changes: 1 addition & 6 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ services:
image: jamesdbloom/mockserver:mockserver-5.7.2
container_name: mockserver
ports:
- "3000:1080"
- "3001:1090"
- "1080:1080"

selenium-hub:
image: selenium/hub:3.141
Expand All @@ -20,8 +19,6 @@ services:
chrome:
image: selenium/node-chrome:3.141
container_name: chrome
ports:
- "5900:5900"
volumes:
- /dev/shm:/dev/shm
depends_on:
Expand All @@ -33,8 +30,6 @@ services:
firefox:
image: selenium/node-firefox:3.141
container_name: firefox
ports:
- "5901:5900"
volumes:
- /dev/shm:/dev/shm
depends_on:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.github.sergiomartins8</groupId>
<artifactId>ui-automation-bootstrap</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
<packaging>maven-archetype</packaging>

<name>ui-automation-bootstrap</name>
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/archetype-resources/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ services:
image: jamesdbloom/mockserver:mockserver-5.7.2
container_name: mockserver
ports:
- "3000:1080"
- "3001:1090"
- "1080:1080"
- "1090:1090"
#end

selenium-hub:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import static com.codeborne.selenide.WebDriverRunner.getWebDriver;

/**
* Holds methods that initialize (and teardown) the required driver; locally or remotely.
* Holds methods that initialize and teardown the required driver; locally or remotely.
* <br>
* Also, an instance to the {@link Browser} in which browser actions can be performed
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,23 @@
package ${package}.base;

#if (${mockserver} == 'true')
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
import ${package}.utils.config.CustomConfiguration;
#end
import ${package}.utils.logging.Loggable;

/**
* Where it all starts.
* <br>
* The framework is initialized here with all the required configurations.
#if (${mockserver} == 'true')
* It also takes care of the {@link MockContext} initialization and teardown.
#end
*/
public abstract class FrameworkBootstrap implements Loggable {
#if (${mockserver} == 'true')

/**
* Tells {@link MockContext} to initialize the mock server if it is present as a system property.
*/
@BeforeSuite
public void initializeMockServer() {
if (CustomConfiguration.mockServerAddress != null) {
MockContext.initializeMockServerClient();
}
public void initializeGlobalConfigurations() {
logger().info("Initialize global configurations");
}

/**
* Tells {@link MockContext} to reset the mock server data if it is present as a system property.
*/
@AfterSuite
public void teardownMockServer() {
if (CustomConfiguration.mockServerAddress != null) {
MockContext.resetMockServerClient();
}
public void teardownGlobalConfigurations() {
logger().info("Teardown global configurations");
}
#end
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,24 @@
import ${package}.utils.config.CustomConfiguration;

/**
* Context for objects for mocking purposes.
* Holds methods that allow mock external dependency services.
*/
public class MockContext {

private static MockServerClient mockServerClient;

/**
* Initializes the mock server client based on {@link CustomConfiguration} settings.
* Instantiates {@link #mockServerClient} object if it needs to be instantiated.
* <br>
* Synchronized enssures the singleton client instance.
*
* @return mock server client instance
*/
public static void initializeMockServerClient() {
MockContext.mockServerClient = new MockServerClient(
getMockServerHost(),
getMockServerPort());
}

public static void resetMockServerClient() {
mockServerClient.reset();
}
public static synchronized MockServerClient getMockServerClient() {
if (mockServerClient == null) {
mockServerClient = new MockServerClient(getMockServerHost(), getMockServerPort());
}

public static MockServerClient getMockServerClient() {
return mockServerClient;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void testExampleOne() {
@Test(description = "Test based on mock server expectations")
public void testExampleTwo() {
// This is just an example of the expectation currently being mocked by using MockServer on ${localhost}
open("http://mockserver:3000/login");
open("http://mockserver:1080/login");

logger().info("Example info log");
logger().warn("Example warn log");
Expand Down
5 changes: 3 additions & 2 deletions src/test/resources/projects/ui_tests/goal.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
test \
-Dselenide.remote=http://0.0.0.0:4444/wd/hub \
-Dmock.server.address=0.0.0.0:3000 \
-Dlistener=io/company/utils/listeners/MockServerListener.java
-Dmock.server.address=0.0.0.0:1080 \
-Dlistener=io/company/utils/listeners/MockServerListener.java \
-Dselenide.browser=firefox