Github Class AutoGrader not autograding

I use Eclipse, Java, and JUnit test cases in my class and would like to use the new autograding feature, but it isn’t working for me. Could use help figuring out why.

I have looked at the sample repo here: https://github.com/education/autograding-example-java

The JUnit tests seemed to be run correctly the first time (although it could be that I was just excited to see the “all test passed” and missed some of the nuances of the build output. Now, it appears like gradle isn’t finding my source, even though the JUnit tests run fine inside of Eclipse.

Here is output from the GitHub action:

Run education/autograding@v1 11s

Points 90/90

Starting a Gradle Daemon (subsequent builds will be faster)

Task :compileJava NO-SOURCE
Task :processResources NO-SOURCE
Task :classes UP-TO-DATE
Task :compileTestJava NO-SOURCE
Task :processTestResources NO-SOURCE
Task :testClasses UP-TO-DATE
Task :test NO-SOURCE

BUILD SUCCESSFUL in 9s

:white_check_mark: StepTrackerTest.java

::8db056cb-6a19-4858-b750-e33936fc9f86::
All tests passed

===================================
My StepTrackerTest.java looks like this:
package q2;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

//import
class StepTrackerTest {

@Test
@DisplayName("Initial State Case")
void testStepTracker1(){
	StepTracker tr = new StepTracker(10000);
	assertEquals(0, tr.activeDays());
	
}

//Should see this 2.
@Test
void testStepTracker2(){
StepTracker tr = new StepTracker(10000);
assertEquals(1.0, tr.averageSteps());

}

}

The jUnit tests run fine inside of Eclipse and I am doing a commit and push up to my repository. So, I believe the files are in the right place.

I have moved the class and the jUnit test case file in and out of package and that doesn’t seem to matter.

Any thoughts on what is amiss?
Thanks,
Dave

1 Like

:wave: @liberty-bradleyd!

My gut feeling here is that Eclipse is helping JUnit find all the relevant source code. Java IDEs are really good at making things work fairly seamlessly with a click of a button, but when running tests on the command line, it’s a little more tricky sometimes.

Could you share your rough directory structure, and the run command you’re using? If you have access to a linux / mac machine, it may also help to try running tests on the command line instead of Eclipse. When you get that working, that same command will work with Classroom autograding.

When we figure this out, let’s see how we might be able to improve the Classroom experience :slight_smile:

Cheers,

Nathaniel
Program Manager - GitHub Classroom

Thanks Nathaniel,

That would be great. I agree that other users will run into a similar fate, so ironing this out now will help others too.

Here is my rough directory structure:

project root(c:\users\myusername\git\2019-q2a-liberty-bradleyd)
->build.gradle
->.classpath
->.gitignore
->.git
------>branches
->.github
------>classroom
--------->autograding.json
------>workflows
--------->classroom.yml
->.settings
-> bin
-> src
-------> q2
----------->StepTracker.java
----------->StepTrackerTest.java

  • Eclipse is in C:\Program Files (x86)\Eclipse\
  • JUnit5 is in C:\Program Files (x86)\Eclipse\plugins\org.junit.jupiter.api_5.0.0.v20170910-2246.jar
  • the CLASSPATH environment variable is set to:
    CLASSPATH=.;C:\Program Files (x86)\Java\jdk1.8.0_231\bin;C:\Program Files (x86)\Eclipse\plugins\org.junit_4.12.0.v201504281640/;

Unfortunately or I might say fortunately, I only have access to Windows computers :slight_smile:

Thanks for the help,
Dave

I’ll do a write up tomorrow, but it turns out there are specific directory structure requirements for gradle.

See here: https://stackoverflow.com/questions/26634000/gradle-skipping-task-compilejava-as-it-has-no-source-files

One StackOverflow post shows how to do that in Eclipse here:

Well…this is a bit frustrating.

If you create the directory structure that contains the two subfolders it just works:
src/main/java
src/test/java

But, that is not the default setup in Eclipse, so I was trying to get it to work with using the default src folder in Eclipse by adding a sourceSets section to build.gradle like this:

sourceSets {
    main {
        java {
            srcDirs = ["src"]
        }
    }
}

That allows gradle to find the source, but I then get a compile error stating that it cannot find JUnit.

I don’t know enough about gradle to figure out why that isn’t working even though the build.gradle has this:
dependencies {
testImplementation(‘org.junit.jupiter:junit-jupiter:5.6.0’)
implementation(‘org.junit.jupiter:junit-jupiter:5.6.0’)
}

Hey @liberty-bradleyd,

I’m glad you’re making progress! Admittedly, I don’t know enough about Gradle to figure this out either. Perhaps someone else in the community does!

Hi Nathaniel,

Ok - I figured it out. You can specify the root folder for both source files and test files by adding a sourceSets section to the build.gradle file. So, my recommendation would be to change the example to be more flexible by adding a section like this to the build.gradle file:

build.gradleExample.pdf

sourceSets {
    main {
        java {
            srcDirs = ["src", "main/java"]
	}
    }
    test {
       java {
           srcDirs = ["src", "test/java"]
        }
    }
}
© 2017 GitHub, Inc.
with by
GitHub Education