PureSoul
PureSoul

Reputation: 1

Im built a docker file for selenide java testing but all the e2e test are not running and only the api test are wroking

when I'm trying to run only e2e in the docker its says 0 tests. I believe the problem is in the chrome and chrome driver installation in the docker file. I tried many things but noting had worked and I'm getting no errors.

FROM openjdk:21-ea-21-jdk-slim AS BUILD

# Set the working directory in the container
WORKDIR /app

# Copy the Maven configuration file (pom.xml) to the container
COPY pom.xml .

# Copy the source code into the container
COPY . .

# Build your application with Maven
#RUN apk add --no-cache maven && mvn clean package
RUN apt-get update && \
     apt-get install -y maven && \
     apt-get clean;

RUN apt-get update -y && apt-get install -y wget xvfb unzip jq
RUN apt-get update && apt-get install -y curl

RUN apt-get update && apt-get install -y chromium


# Install Google Chrome dependencies
RUN apt-get install -y libxss1 libappindicator1 libgconf-2-4 \
    fonts-liberation libasound2 libnspr4 libnss3 libx11-xcb1 libxtst6 lsb-release xdg-utils \
    libgbm1 libnss3 libatk-bridge2.0-0 libgtk-3-0 libx11-xcb1 libxcb-dri3-0


# Fetch the latest version numbers and URLs for Chrome and ChromeDriver
RUN curl -s https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json > /tmp/versions.json

RUN CHROME_URL=$(jq -r '.channels.Stable.downloads.chrome[] | select(.platform=="linux64") | .url' /tmp/versions.json) && \
    wget -q --continue -O /tmp/chrome-linux64.zip $CHROME_URL && \
    unzip /tmp/chrome-linux64.zip -d /opt/chrome

RUN chmod +x /opt/chrome/chrome-linux64/chrome


RUN CHROMEDRIVER_URL=$(jq -r '.channels.Stable.downloads.chromedriver[] | select(.platform=="linux64") | .url' /tmp/versions.json) && \
    wget -q --continue -O /tmp/chromedriver-linux64.zip $CHROMEDRIVER_URL && \
    unzip /tmp/chromedriver-linux64.zip -d /opt/chromedriver && \
    chmod +x /opt/chromedriver/chromedriver-linux64/chromedriver

# Set up Chromedriver Environment variables
ENV CHROMEDRIVER_DIR /opt/chromedriver
ENV PATH $CHROMEDRIVER_DIR:$PATH

ENV MAVEN_HOME /usr/share/maven
ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"

# Run the application when the container starts
CMD ["mvn", "test"]
INFO] 
2024-03-17T19:56:38.573205002Z [INFO] -------------------------------------------------------
2024-03-17T19:56:38.573276927Z [INFO]  T E S T S
2024-03-17T19:56:38.573561943Z [INFO] -------------------------------------------------------
2024-03-17T19:56:39.635558976Z [INFO] Running TestSuite
2024-03-17T19:56:59.738518367Z [TestNG-tests-1] INFO framework.cleanup.CleanupThread - Thread started
2024-03-17T19:57:02.483653897Z [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 22.82 s -- in TestSuite
2024-03-17T19:57:02.820011928Z [INFO] 
2024-03-17T19:57:02.820063444Z [INFO] Results:
2024-03-17T19:57:02.820072141Z [INFO] 
2024-03-17T19:57:02.821374723Z [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
2024-03-17T19:57:02.821432691Z [INFO] 
2024-03-17T19:57:02.825335558Z [INFO] ------------------------------------------------------------------------
2024-03-17T19:57:02.825405780Z [INFO] BUILD SUCCESS
2024-03-17T19:57:02.826307320Z [INFO] ------------------------------------------------------------------------
2024-03-17T19:57:02.827949419Z [INFO] Total time:  02:25 min
2024-03-17T19:57:02.828526872Z [INFO] Finished at: 2024-03-17T19:57:02Z
2024-03-17T19:57:02.829058800Z [INFO] ------------------------------------------------------------------------

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.2.5</version>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.surefire</groupId>
                        <artifactId>surefire-testng</artifactId>
                        <version>3.1.2</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <!-- Create report even if there are test failures -->
                    <testFailureIgnore>true</testFailureIgnore>
                    <argLine>
                        --enable-preview -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                    </argLine>
                    <suiteXmlFiles>
                        <suiteXmlFile>src/test/resources/SuiteCollection.xml</suiteXmlFile>
                    </suiteXmlFiles>
                </configuration>
            </plugin>

I tried to use different installation in docker but noting has solved the problem. only the api tests are running but not the e2e tests.

Upvotes: 0

Views: 155

Answers (1)

Warlike
Warlike

Reputation: 101

If names of your e2e test classes end with IT (f.e. MyTestCaseIT.java) then mvn test should not execute it by default. You need to use mvn verify instead.

Upvotes: 1

Related Questions