Skip to content

Instantly share code, notes, and snippets.

@ssirowy
Created December 9, 2015 22:12
Show Gist options
  • Save ssirowy/66c7eb12d91f88d3ff1e to your computer and use it in GitHub Desktop.
Save ssirowy/66c7eb12d91f88d3ff1e to your computer and use it in GitHub Desktop.
/**
* Instructors in our system have the ability to write a *unit test* against their students code
* using the following interface. The *only* thing they can edit is the contents of the `passed` function.
* But, they can create a student's object, run their own code, and pass us a true/false value as to whether
* the test passed.
*/
public class zyLabsUnitTest {
public boolean passed() {
// Write your code here.
// e.g return student_add(4, 2) == 6;
}
}
/**
* This has worked well, but now instructors want to give their students more information, ideally by just writing
* to System.out.println() regarding the test.
* e.g Testing your `add` function with 4 and 2.
* But they dont want to pollute the students output with their output, so we want to provide some sort of method to
* allow them to write content, ideally by passing something into the `passed` method.
* e.g
*/
public class zyLabsUnitTest {
public boolean passed(SomeStream s) {
s.write('Testing your code with a string');
return some_func('test string');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment