COVID-19 Notice
Due to the COVID-19 outbreak, this website is being retired effective March 15, 2020. All future updates will be moved to Canvas for online instruction as advised by the university.
Every homework comes with a test
directory with JUnit 5 test code. You must pass all of these tests using the homework
script on the lab computers.
You should try passing the tests locally before you try passing them remotely. Before you can do that, you need to follow the homework setup guide to setup the your repository using Github classroom and then import that repository as a Java Project in Eclipse.
To run the JUnit tests provided with the homework template, follow these steps:
Open up the test
subfolder in the Eclipse project.
Open up the class containing the same name as the homework assignment plus the suffix Test
at the end. For example, for the ArgumentParser
homework assignment, ArgumentParserTest
is the associated test class.
From the “Run” menu, select “Run As” » “JUnit Test” from the menu. If prompted which tests to run, select the one with the same name as the class. For example, for the ArgumentParser
homework assignment, ArgumentParserTest
is the associated test class. This will be the set of tests run by the homework
script on the lab computers.
You can run just the nested tests or one test at a time if you want. This can help you focus on a small number of tests at a time as you develop the code. To do this, right-click the test method or nested test class, and select “Run As” » “JUnit Test” from the popup menu.
Running the tests should open the “JUnit” view. You can use that view to see which tests you are passing and which you are not. See the Eclipse User Guide for what each of the buttons mean in this view.
After making changes to your code, you can re-run the tests by following the same steps or clicking the Rerun Test button.
It is important you only try to pass one test at a time, because the changes you make may affect other tests. You should git commit
your changes every time you start passing a new test at a minimum, and git push
your changes at the end of every coding session.
Once you are passing all of the tests locally, it is time to test your homework remotely. There are two primary steps to this process: committing and pushing your changes to Github, and then logging into a CS Lab computer and running the homework
script.
After you have updated your remote Github repository, login to a CS lab computer and run the following command from a terminal:
Replace USER
with your Github username, ORG
with the Github organization for your section (either usf-cs212-2020
for CS 212-01 or usf-cs212-spring2020
for CS 212-02), and HOMEWORK
with the name of the homework (e.g. ArgumentParser
). For example:
This script will clone your remote Github repository, fetch fresh test code (in case you changed anything) from the template repository, compile the Java code, and then run all of the JUnit tests and report how many tests passed or failed. This script is used for grading homework.
If you want the detailed output of running the tests, you can add the --keep
flag to the command. This will leave the downloaded and compiled homework files in a directory named ~/cs212-HomeworkName-????
where ~/
is your home directory and ????
is a randomly generated string. If you are familiar working on the terminal, you can then look at the output generated by the script, rerun the tests via the terminal, or modify and recompile the source code.
Careful! Every time you run the homework
script with the --keep
flag, it creates a new copy of your code. If you do not remember to remove those directories manually up after you are done debugging, you can eventually use up your entire space quota on the lab computers!
You will be doing this quite a bit, so I recommend making an alias. To do this, open the ~/.bashrc
file on a lab computer and add the following line:
Replace USER
with your GitHub username and ORG
with your Github Classroom organization. Run source ~/.bashrc
for the command to take affect.
If you are uncomfortable with editing a file via the command line, you can run this command on a lab computer to do it for you:
Again, make sure to replace USER
with your GitHub username and ORG
with your Github Classroom organization BEFORE copying and pasting the command!
Then, you can test homework using the following command on the lab computers:
Replace HOMEWORK
(the uppercase one) with the name of the homework you want to test. The alias will still work with the --keep
flag as well!
You only need to set the alias once. Every time you login again, the .bashrc
file will re-add that alias for you.