-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat] Add option to run student test classes instead of reference te…
…sts (#57)
- Loading branch information
Showing
12 changed files
with
316 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"""Exceptions for the junit4 plugin. | ||
.. module:: _exception | ||
:synopsis: Exceptions for the junit4 plugin. | ||
.. moduleauthor:: Simon Larsén | ||
""" | ||
|
||
import repobee_plug as plug | ||
|
||
from repobee_junit4 import SECTION | ||
|
||
|
||
class ActError(plug.PlugError): | ||
"""Raise if something goes wrong in act_on_clone_repo.""" | ||
|
||
def __init__(self, hook_result): | ||
self.hook_result = hook_result | ||
|
||
|
||
class JavaError(ActError): | ||
"""Raise if something goes wrong with Java files.""" | ||
|
||
def __init__(self, msg): | ||
res = plug.HookResult(hook=SECTION, status=plug.Status.ERROR, msg=msg) | ||
super().__init__(res) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
tests/integration_tests/repos/student-with-bad-tests-week-10/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This repo should pass all tests |
23 changes: 23 additions & 0 deletions
23
tests/integration_tests/repos/student-with-bad-tests-week-10/src/Fibo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Class for calculating Fibonacci numbers. | ||
*/ | ||
|
||
public class Fibo { | ||
private long prev; | ||
private long current; | ||
|
||
public Fibo() { | ||
prev = 0; | ||
current = 1; | ||
} | ||
|
||
/** | ||
* Generate the next Fibonacci number. | ||
*/ | ||
public long next() { | ||
long ret = prev; | ||
prev = current; | ||
current = ret + current; | ||
return ret; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
tests/integration_tests/repos/student-with-bad-tests-week-10/src/FiboTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import static org.hamcrest.CoreMatchers.*; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.junit.Assert.*; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
public class FiboTest { | ||
@Test | ||
public void correctlyGeneratesFirst10Numbers() { | ||
Fibo f = new Fibo(); | ||
long[] expected = {0, 1, 1, 2, 3, 5, 8, 13, 21, 34}; | ||
long[] actual = new long[10]; | ||
|
||
for (int i = 0; i < 10; i++) { | ||
actual[i] = f.next(); | ||
} | ||
|
||
assertThat(actual, equalTo(expected)); | ||
} | ||
|
||
@Test | ||
public void correctlyGeneratesFiftiethNumber() { | ||
// note that the first number is counted as the 0th | ||
Fibo f = new Fibo(); | ||
|
||
for (int i = 0; i < 50; i++) { | ||
f.next(); | ||
} | ||
|
||
assertThat(f.next(), equalTo(12586269025l)); | ||
} | ||
|
||
@Test | ||
public void failingTest() { | ||
fail("Student wrote a bad test"); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
tests/integration_tests/repos/student-with-duplicate-tests-week-10/FiboTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import static org.hamcrest.CoreMatchers.*; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.junit.Assert.*; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
public class FiboTest { | ||
@Test | ||
public void correctlyGeneratesFirst10Numbers() { | ||
Fibo f = new Fibo(); | ||
long[] expected = {0, 1, 1, 2, 3, 5, 8, 13, 21, 34}; | ||
long[] actual = new long[10]; | ||
|
||
for (int i = 0; i < 10; i++) { | ||
actual[i] = f.next(); | ||
} | ||
|
||
assertThat(actual, equalTo(expected)); | ||
} | ||
|
||
@Test | ||
public void correctlyGeneratesFiftiethNumber() { | ||
// note that the first number is counted as the 0th | ||
Fibo f = new Fibo(); | ||
|
||
for (int i = 0; i < 50; i++) { | ||
f.next(); | ||
} | ||
|
||
assertThat(f.next(), equalTo(12586269025l)); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
tests/integration_tests/repos/student-with-duplicate-tests-week-10/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This repo should pass all tests |
23 changes: 23 additions & 0 deletions
23
tests/integration_tests/repos/student-with-duplicate-tests-week-10/src/Fibo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Class for calculating Fibonacci numbers. | ||
*/ | ||
|
||
public class Fibo { | ||
private long prev; | ||
private long current; | ||
|
||
public Fibo() { | ||
prev = 0; | ||
current = 1; | ||
} | ||
|
||
/** | ||
* Generate the next Fibonacci number. | ||
*/ | ||
public long next() { | ||
long ret = prev; | ||
prev = current; | ||
current = ret + current; | ||
return ret; | ||
} | ||
} |
Oops, something went wrong.