Java (Gradle)

To create a new assignment in Java (Gradle), click into one of your courses, and then click Add assignment. Choose Java (Gradle) from the drop-down list of available backend languages and set the the rest of your assignment's parameters (deadline, etc.). Once the assignment is created, a new folder will be created in the private GitHub/GitLab template repository for the course in which you are added this assignment. This folder will contain a standard Gradle project structure:

Automated test-suite setup

If you would like to add tests that are automatically run by CodeScreen against each student's solution to your assignment, you can add these as test classes in the src/test/java/ directory.

All unit test filenames must end with "Test" and all unit test filesnames that end with "HiddenTest" will not be visible to the student. These hidden unit tests allow you to test students' solutions against edge cases etc.

If you want to add files that your hidden unit tests use and hence are also not visible to the student, the names of these files must begin with hidden (case-insensitive), e.g., hiddenFoo.json, hiddenFoo.csv, HiddenFoo.java, etc.

All unit tests must use the Junit test framework and the build.gradle file may only be updated to add dependencies required for your coding assignment.

The assignment must be compatible with Java 17.

GitHub Action & GitLab CI/CD

AssignmentOS uses either GitHub Actions or GitLab CI/CD (depending on whether you use GitHub or GitLab) to run automated unit tests. We provide the following GitHub Action & GitLab CI/CD file for Java (Gradle) assignments. Note that this file is added dynamically to the repo of each student taking your assignment, so please do not include it in your template repo. This file also cannot be changed.

GitHub Action .yml fileGitLab CI/CD .yml file
name: Java CI

on: [push]

jobs:

  run-unit-tests:

    runs-on: ubuntu-latest

    steps:
    
    - uses: actions/checkout@v3
    
    - name: Set up JDK 1.17
      uses: actions/setup-java@v3
      with:
        distribution: oracle
        java-version: 17
        
    - name: Access ./gradlew file
      run: chmod +x ./gradlew
      
    - name: Build and Test
      run: ./gradlew test

Coming soon!

Examples

An example Java assignment that uses automated test suite scoring can be seen here: https://github.com/AssignmentOS-HQ/Java-Gradle-AssignmentOS-Fibonacci.

Last updated