GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng
Overview Version control Git JUnit
Version Control Managing change Cooperation between people within a team Problem correction Alternative versions
Version Control Repository Check in Check out File locking Merging Labels and tagging Branching
Git Distributed version control Own copy of source directory Snapshot of the source directory Eclipse comes with GIT It needs setting up
Git Set up an account on a Git server GitLab Set up a new Git repository Generate an SSH key and add it GitLab Eclipse Commit code to GitHub
Git Set up an account CS servers Use CS account
Git
Now create a project Use to deposit code
Git
Now you need to copy in a key from Eclipse If you don’t have one, create one
Git
Now set up a remote connection so Eclipse can talk to GitLab You will need the info from GitLab
Git
Now set up windows You need to set an environment variable
Git
Now you can create a repository in on your local machine Then add the code to GitLab
Git
Now you can use Git Commit your code
Git
Team Push Pull Merge tool Branching Advanced -> tag Project and file Different Team menus.
JUnit Test your code in parts! Create a JUnit test case Write the test code Use asserts Run the test case
JUnit
import org.junit.Assert.*; public class TestMyClass public static void setUpClass() throws public static void setup() throws public void testMethod(){} } class
JUnit
Asserts assertEquals(boolean expected, boolean actual) assertTrue(boolean expected, boolean actual) assertFalse(boolean expected, boolean actual) assertNotNull(Object object) assertSame(Object object) assertNotSame(Object object) assertArrayEquals(Object object)
JUnit Use asserts to check for things that should never happen Array over runs Null pointers Wrong values Divide by zero Check your assumptions Use exceptions for things that can go wrong! IO errors Memory errors User inputs
JUnit Sunny Day Test for what you expect As specified What can go wrong?
Questions?