Unit-testing

Unit-testing - public void testGetName() {

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
1 COE318 Fall 2008, Olivia Das, Elec. and Comp. Engg., Ryerson University Unit Testing Individual testing of separate units of a software system In O-O, these units typically are classes and methods Netbeans provides you the tools to record and replay tests Helps in Regression testing JUnit – A regression testing framework
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 COE318 Fall 2008, Olivia Das, Elec. and Comp. Engg., Ryerson University Unit Testing in Netbeans
Background image of page 2
3 COE318 Fall 2008, Olivia Das, Elec. and Comp. Engg., Ryerson University
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 COE318 Fall 2008, Olivia Das, Elec. and Comp. Engg., Ryerson University (For reference: In Netbeans, click Help -> Help Contents -> Search for Junit) To Create a test for a single Java class. Select the class in the Source Editor, Projects window, or Files window and choose Tools > Create JUnit Tests (Ctrl-Shift-U). Set the parameters for the test skeleton generator in the Create Tests dialog box and click OK.
Background image of page 4
5 COE318 Fall 2008, Olivia Das, Elec. and Comp. Engg., Ryerson University
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 6
Background image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: public void testGetName() { System.out.println("getName"); Person instance = null; String expResult = ""; String result = instance.getName(); assertEquals(expResult, result); // TODO review the generated test // code and remove the default call to fail. fail("The test case is a prototype."); } Generated testGetName method in PersonTest Class 6 COE318 Fall 2008, Olivia Das, Elec. and Comp. Engg., Ryerson University public void testGetName() { System.out.println("getName"); Person instance = new Person("olivia"); String expResult = "olivia"; String result = instance.getName(); assertEquals(expResult, result); // TODO review the generated test code // and remove the default call to fail. //fail("The test case is a prototype."); } 7 COE318 Fall 2008, Olivia Das, Elec. and Comp. Engg., Ryerson University Running Tests Run a class's test by selecting the test class node itself and choosing Run > Run File > Run testclassname (Shift-F6)....
View Full Document

Page1 / 7

Unit-testing - public void testGetName() {

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online