2.4.2 Failed GitHub workflow

Hello! I have just started the MoT automation foundation course. In section ā€˜2.4.2 Adding a Framework to a Pipelineā€™ I received an error. What could be the reason and how should I solve it?

2 Likes

Do you have a test class named LoginTest?
The error message states that no test class matching that pattern can be found.
Please check the correct spelling, and also upper/lowercase.

1 Like

I can see that it is unable access your jarfile. Could the path be wrong? I can see forward slashes in the path to your jarfile.

2 Likes

Stupid meā€¦ totally forgot that for me at first it also wasnā€™t running.

The build jardidnā€™t match the pattern given in the build_test_maven.yml.
I adapted the run in the Run E2E checks section to java -jar target//mot-cert-support-app-java-*-exec.jar and that did the trick for me.

2 Likes

The issue is still not fixed. :person_in_lotus_position:t2: I tried a lot of different things but nothing helped. However, Iā€™m receiving a bit different error now:

In class instructions, there was information to create new files in src/test while there was no such folder, only src/main, so I created my files there. Can this be related?

1 Like

By the way, I also needed to update my yml file from actions/checkout@v3 to actions/checkout@v4 and from actions/setup-java@v3 to actions/setup-java@v4 because I received the following error:

1 Like

Thanks for sharing those details.

So I can see your LoginTest file is within the src/main/java part of the project. It needs to be in src/test for Maven to be able to see the file. Create a the folders src/test/java and move the LoginTest class in there.

4 Likes

Still nothing works. :slight_smile:

Could you make your repo public and provide the link?
That would make it so much easier to analyse and make the right suggestions.

1 Like

@erikaandri I tracked down your repository and took a look at your latest failure and it looks there has been a change in your error. You are now successfully running your test, but itā€™s failing because it canā€™t access the app.

My recommendation is to update lines 20 and 21 in your yaml file to the following:

java -jar target/mot-cert-support-app-java-*-exec.jar &
curl --head -X GET --retry 60 --retry-connrefused --retry-delay 1 http://localhost:8080

The first change is an addition of & at the end of the first line. This means donā€™t wait for the app to run, move onto the next step. The second change replaces the sleep 10 in favour of sending an HTTP request every second to check if the app is up. Once the app is up, we can progress. If the app isnā€™t up after 60 seconds, it will fail.

2 Likes

Unfortunately, this change didnā€™t help as well. :frowning:

Apologies I was looking at the wrong part of your YAML. I was offering corrections to the E2E portion of your YAML when itā€™s this part that is failing:

   - name: Build project and run unit and API checks
    run: mvn --batch-mode package

The reason itā€™s failing is because youā€™ve moved your E2E test into an area in which the Unit and API checks are. Meaning itā€™s getting picked up at the wrong time in your pipeline and ran. It fails because you donā€™t have the app up and running at that point.

So what you need to do is follow the excludes pattern that is in your POM.xml file (lines 51-53):

<excludes>
   <exclude>**/e2e/**/**.java</exclude>
</excludes>

This is saying any tests that are in the e2e package should be ignored for the Unit and API tests.

In a nutshell, move your LoginTest into a new package entitled e2e and it will be ignored during the Unit and API run. Then you explicitly run it later in the pipeline.

2 Likes