git and junit dr. andrew wallace phd beng(hons) euring [email protected]

55
GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng [email protected]

Upload: nigel-skinner

Post on 01-Jan-2016

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

GIT and JUnitDr. Andrew Wallace PhD BEng(hons) EurIng

[email protected]

Page 2: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Overview

• Version control

• Git

• JUnit

Page 3: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Version Control

• Managing change

• Cooperation between people within a team

• Problem correction

• Alternative versions

Page 4: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Version Control

• Repository• Check in• Check out

• File locking

• Merging

• Labels and tagging• Branching

Page 5: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

• Distributed version control• Own copy of source directory

• Snapshot of the source directory

• Eclipse comes with GIT• It needs setting up

Page 6: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

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

Page 7: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

• Set up an account• CS servers• Use CS account

Page 8: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 9: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 10: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

• Now create a project

• Use to deposit code

Page 11: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 12: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 13: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 14: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

• Now you need to copy in a key from Eclipse

• If you don’t have one, create one

Page 15: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 16: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 17: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 18: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 19: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

• Now set up a remote connection so Eclipse can talk to GitLab

• You will need the info from GitLab

Page 20: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 21: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 22: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

• Now set up windows

• You need to set an environment variable

Page 23: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 24: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 25: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

• Now you can create a repository in on your local machine

• Then add the code to GitLab

Page 26: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 27: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 28: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 29: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 30: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 31: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 32: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 33: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 34: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 35: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 36: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

• Now you can use Git

• Commit your code

Page 37: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 38: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 39: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 40: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 41: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 42: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 43: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

Page 44: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Git

• Team• Push• Pull• Merge tool• Branching• Advanced -> tag

• Project and file• Different Team menus.

Page 45: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

JUnit

• Test your code in parts!

• Create a JUnit test case

• Write the test code• Use asserts

• Run the test case

Page 46: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

JUnit

Page 47: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

JUnit

Page 48: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

JUnit

Page 49: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

JUnit

Page 50: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

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

Page 51: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

JUnit

Page 52: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

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)

Page 53: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

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

Page 54: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

JUnit

• Sunny Day• Test for what you expect• As specified

• What can go wrong?

Page 55: GIT and JUnit Dr. Andrew Wallace PhD BEng(hons) EurIng andrew@cs.umu.se

Questions?