Giter Site home page Giter Site logo

Comments (3)

shaharyi avatar shaharyi commented on June 15, 2024

An update:
I found in Gradle CLI docs that you can specify the test classes:
gradle test --tests MyTestClass
But If there is a compilation problem in ANY of the tests, the score is zero.
Only if all tests compile, each of them get their respective points.
Is there a way to easily fix this, perhaps in Gradle or Actions config?

from autograding.

stevenbitner avatar stevenbitner commented on June 15, 2024

I'm no Gradle expert, but I had a similar issue in the past and used the sourceSets attribute to exclude all classes that were not required for a given test. For example:

task test_constructor (type: Test) {
	filter.includeTestsMatching "ConstructorTest"
}

// other test tasks here
// ....

sourceSets {
    if (project.gradle.startParameter.taskNames.contains("test_constructor")) {
        test.java.exclude '**/LotsOfGuessesTest*'
        test.java.exclude '**/TestMain*'
        test.java.exclude '**/TestMainLoop*'
        sourceSets.main.java.excludes = ['Main*']
    }
    else if (project.gradle.startParameter.taskNames.contains("test_loser")) {
        test.java.exclude '**/TestMain*'
        test.java.exclude '**/TestMainLoop*'
        sourceSets.main.java.excludes = ['Main*']
    }
    else if (project.gradle.startParameter.taskNames.contains("test_lots_of_guesses")) {
        test.java.exclude '**/TestMain*'
        test.java.exclude '**/TestMainLoop*'
        sourceSets.main.java.excludes = ['Main*']
    }
    else if (project.gradle.startParameter.taskNames.contains("test_main")) {
        test.java.exclude '**/TestMainLoop*'
    }
}

Then, in my autograding.json file I call the tests one by one. To call the "constructor" test from the Gradle snippet above for instance, the test is:

{
  "name": "Test constructors",
  "setup": "",
  "run": "timeout 60 gradle test_constructor",
  "input": "",
  "output": "",
  "comparison": "included",
  "timeout": 1,
  "points": 20
}

I hope this helps.

from autograding.

shaharyi avatar shaharyi commented on June 15, 2024

from autograding.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.