Grading with JUnit

Grading with JUnit

Codio allows you to easily use JUnit to grade student code. When creating an advanced code test, choose the language under the Execution tab and then choose the unit testing framework you want.

Set the SOURCE PATH field to the directory with the student file. This works best if all of the coding exercise files are in their own directory separate from other student files.

source_path_junit

For ADD CASE, drag the JUnit test file into the field.

test_case_junit

Here is an example of a JUnit test. Note, each assert statement has the variable feedback which contains feedback for the student for each test case.

import static org.junit.Assert.*;
import org.junit.Test;

public class Exercise2Tester {
  
  @Test
  public void checkToString1() {
    String[] members = {"Syd", "Nick", "Roger", "Richard", "David"};
    Band band = new Band("Pink Floyd", "rock'n roll", members);
    String expected = "Band[name=Pink Floyd, genre=rock'n roll, members=[Syd, Nick, Roger, Richard, David]]";
    String actual = band.toString();
    String feedback = "Output did not match.";
    assertEquals(feedback, expected, actual);
  }
  
  @Test
  public void checkToString2() {
    String[] members = {"RZA", "GZA", "ODB", "Method Man", "Ghostface Killah", "Inspectah Deck", "U-God", "Masta Killa", "Cappadonna"};
    Band band = new Band("Wu-Tang Clan", "hip hop", members);
    String expected = "Band[name=Wu-Tang Clan, genre=rap, members=[RZA, GZA, ODB, Method Man, Ghostface Killah, Inspectah Deck, U-God, Masta Killa, Cappadonna]]";
    String actual = band.toString();
    String feedback = "Output did not match.";
    assertEquals(feedback, expected, actual);
  }
  
}

what is the SOURCE PATH I should use. I’m writing my first lab here.

In the video “code/encapsulation/exercises” is used. Where exactly can I find mine? Compile & run tab shows:
Welcome to Ubuntu 22.04.1 LTS (GNU/Linux 6.2.0-1017-aws x86_64)

Last login: Tue Apr 25 15:12:32 2023 from 192.168.10.226
codio@benefitinput-forumfreddie:~/workspace$ javac Main.java && java Main
Does it have to be called Main?
codio@benefitinput-forumfreddie:~/workspace$