git and junit dr. andrew wallace phd beng(hons) euring [email protected]
TRANSCRIPT
GIT and JUnitDr. 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
Git
Git
• Now create a project
• Use to deposit code
Git
Git
Git
Git
• Now you need to copy in a key from Eclipse
• If you don’t have one, create one
Git
Git
Git
Git
Git
• Now set up a remote connection so Eclipse can talk to GitLab
• You will need the info from GitLab
Git
Git
Git
• Now set up windows
• You need to set an environment variable
Git
Git
Git
• Now you can create a repository in on your local machine
• Then add the code to GitLab
Git
Git
Git
Git
Git
Git
Git
Git
Git
Git
Git
• Now you can use Git
• Commit your code
Git
Git
Git
Git
Git
Git
Git
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
JUnit
JUnit
JUnit
JUnit
import org.junit.Assert.*;
public class TestMyClass
{
@BeforeClass
public static void setUpClass() throws Exception{}
@Before
public static void setup() throws Exception{}
@Test
public void testMethod(){}
}
Also @After and @after class
JUnit
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?