5

So I developed a few tests for my Android app and I need to run the tests using github actions workflow. Here is my .yml file, but I don't know how to run the tests( and get their logs):

name: Java CI with Gradle

on:
  push:
  pull_request:
    branches: Features

jobs:
  test:
    name: Run Unit Tests
    runs-on: ubuntu-18.04

    steps:
      - uses: actions/checkout@v1
      - name: set up JDK 1.8
        uses: actions/setup-java@v1
        with:
          java-version: 1.8
      - name: Unit tests
        run: bash ./gradlew test --stacktrace
      - name: Unit tests results
        uses: actions/upload-artifact@v1
        with:
          name: unit-tests-results
          path: ./app

I'm not sure how to run all the app and then run all the tests, can someone give me a hint? I searched all the internet, I came across this code, but it doesn't work. My artifact is the whole app itself The tests are:
1.SignUpTest.java
2.SignInTest.java
3.AddToCart.java

4
  • What's wrong with the Unit tests step? Commented Jun 7, 2020 at 1:55
  • Not sure what it actually happens. The upload artifacts step uploads the whole app, but all i wanted was the logs from tests. Maybe that step is wrong Commented Jun 7, 2020 at 8:20
  • You will need to save the logs from the tests to a file, and then upload the file Commented Jun 7, 2020 at 15:16
  • If any tests fail, GitHub Actions will output the reason. Why do you need to get the logs? Where do you plan to upload them? Commented May 17, 2022 at 20:06

1 Answer 1

1

After some checks apparently there is a more proper way to use Gradle in GitHub actions.

See here.

In addition it seems that you need to upgrade the Gradle permission as shown here.

So this works form me (April 2024):

name: Java CI with Gradle
on:
  push
jobs:
  test_with_gradle:
    runs-on: ubuntu-latest
    steps:
     - uses: actions/checkout@v4
     - uses: actions/setup-java@v4
       with:
         java-version: '17'
         distribution: 'temurin'

    - name: Setup Gradle
      uses: gradle/actions/setup-gradle@v3

    - name: Test
      run: |
        chmod +x gradlew
        ./gradlew test --stacktrace
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.