Best Practices, Introduction to Testing, Junit Framework - PowerPoint PPT Presentation

1 / 33
About This Presentation
Title:

Best Practices, Introduction to Testing, Junit Framework

Description:

Summer 2002. Agenda. Lab 5 Help after class. Lab 6-9 Teams to me today... Exam ... Keep mini (no more than 1-2 days (hours)) Milestones are 0/1. Cover all tasks ... – PowerPoint PPT presentation

Number of Views:104
Avg rating:3.0/5.0
Slides: 34
Provided by: Robert9
Category:

less

Transcript and Presenter's Notes

Title: Best Practices, Introduction to Testing, Junit Framework


1
Best Practices, Introduction to Testing, J-unit
Framework
  • CS2335
  • Summer 2002

2
Agenda
  • Lab 5 Help after class
  • Lab 6-9 Teams to me today
  • Exam 2 July 8
  • Lecture
  • Best Practices
  • Test Intro
  • JUnit

3
Miniature Milestones
  • Problem Im 90 done.
  • Technique
  • Developers create their own estimate.
  • Keep mini (no more than 1-2 days (hours))
  • Milestones are 0/1
  • Cover all tasks
  • Use to cover short-term
  • Assess and re-estimate frequently.
  • Phase Project Management

4
Change Board
  • Problem Uncontrolled changes, lack of
    prioritization on bug fixes, Code/Fix cycle
  • Technique
  • Create a board of representatives
  • Board has authority to accept/reject changes
  • Changes are considered before they are made
  • Side Effects are considered
  • Phase Configuration Management

5
Daily Smoke and Build Test
  • Problem Unsuccessful Integration, low quality,
    poor progress visibility
  • Technique
  • All code modules turned in frequently.
  • Developers keep code in buildable form.
  • All interfaces are stubbed out.
  • Smoke tests run automatically.
  • Dummy code used where necessary.
  • Breaking the build usually earns a prize.
  • Phase Implementation, Code Integration

6
Incremental Integration
  • Problem Code integration fails. Big-bang
    approach frequently used. Excessive schedule
    spent in integration phase.
  • Technique
  • Use proven integration technique
  • Top-down
  • Bottom-up
  • Hybrid
  • Phase Integration

7
Software Quality Assurance
  • Process (Analysis, Design, Code, Test)
  • Reviews/Inspections
  • Multi-tiered Testing Strategy
  • Configuration Control (Code/Docs)
  • Standards Compliance
  • Measurement/Reporting

8
Software Quality Factors
Portability Reusability Interoperabilty
Maintainability Flexibility Testability
Correctness, Reliablity, Efficiency,
Integrity Usability
9
Two Key Concepts
  • Validation Are we building the right thing?
    Conformance to customer requirements and quality
    attributes.
  • Verification Are we building the thing right?
    Process conformance, quality activities.

10
Where does testing fit in?
PHASE O Testing Debugging
PHASE 1 Testing shows the software works
PHASE 2 Testing shows the software doesnt work
PHASE 3 Testing doesnt prove anything, it
reduces risk of unacceptable
software delivery.
PHASE 4 Testing is not an act, a mental
discipline of quality.
11
The Testing Quote
Testing cannot show the absence of defects, it
can only show that software defects are present.
We cannot test quality into a product, we have to
design it in.
12
Test Objectives
  • Tests intended to find errors
  • Good test cases have high p for finding a yet
    undiscovered error
  • Successful tests cause program failure, i.e. find
    an undiscovered error.
  • Minimal set of test cases needs to be developed
    because exhaustive testing not possible

13
What we have here
  • Developers do everything they can to make the
    software work.
  • Testers do everything they can to make the
    software fail.

14
Testing Paradox
Every method you use to prevent or find bugs
leaves a residue of subtler bugs against which
those methods are ineffective.
Cost
Defects Found
Time
15
Testing Phases
  • Unit
  • Integration
  • Component
  • System
  • Usability
  • Regression
  • Validation
  • Alpha/Beta (FUT/OT)

16
Vocabulary
  • Test Case a set of data/events provided for a
    specific test.
  • Test Suite a set of test cases.
  • Test Driver a program written to test a unit
    module
  • Test Stub a module written to test a higher
    level component
  • Test Harness a test environment to run the stubs
    and drivers and check the results.

17
Types of testing
  • Structural (Whitebox)
  • Functional (Blackbox)
  • Statistical (Random)
  • Mutation
  • Object Oriented (State-based)
  • Insert latest PhD thesis topic here

18
Return of the Vocabulary
  • Coverage a measure of the amount of testing to
    be achieved. Normally spoken of in standard
    criteria based upon test technique for a subset
    of test cases.
  • Adequacy a measure of the overall efficiency and
    effectiveness of the test suite.

19
Writing a test plan
  • Introduction
  • Purpose
  • Program Description
  • Test Environment
  • Test Case Descriptions
  • Coverage Criteria
  • Details

4. Summary
20
Stubbing Functions
int main (int argc, char argv) if (argclt4)
usage() double x f(argv1,argv2)
void usage() return double f(char
arg1, char arg2) return 3.0
21
Writing Drivers
int main( int argc, char argv) int i
for (i0 ilt10i) printf(SQRT of i is
i, i, sqrt(i))
22
Why does testing go bad?
  • Schedule compression/ Waterfall
  • Writing harnesses, suites,stubs and drivers
    doesnt relate directly to LOC.
  • Different philosophys
  • Overconfidence in silver bullets

23
What is xUnit?
  • An automated unit test framework
  • Provides the Driver for unit(s)
  • Provides automatic test runs
  • Provides automatic result checks
  • Available for multiple languages
  • cppUnit
  • sUnit
  • Junit

24
Junit Terms
  • Failure Expected
  • Error Unexpected
  • TestCase Collection of method tests
  • Test Fixture Object Reuse
  • TestSuite Collection of Test Cases
  • TestRunner Interface
  • awt, swing,text

25
Using Junit (Create Fixture)
  • public class ComplexTest extends TestCase
  • Complex c1
  • Complex c2
  • protected void setUp()
  • c1 new Complex(7,3)
  • c2 new Complex(12,6)
  • protected void tearDown()

26
Using Junit (Add Test Cases)
  • public void testAdd()
  • Complex result c1.Add(new Complex(5,3))
  • assertEquals(result.get_r(),c2.get_r())
  • assertEquals(result.get_i(),c2.get_i())
  • public void testEqual()
  • assertTrue(!c2.Equal(c1))
  • assertTrue(c1.Equal(new Complex(7,3)))

assertNull, assertNotNull, assertSame
27
Using Junit (Make Suite)
  • public static Test suite()
  • TestSuite suite new TestSuite()
  • suite.addTest(new ComplexTest(testAdd))
  • suite.addTest(new ComplexTest(testEqual))
  • return suite

28
Using Junit (Invoke)
  • public static void main(String args)
  • junit.textui.TestRunner.run(suite())
  • public ComplexTest(String s)
  • super(s)

29
The Graphical UI
30
UI on Failure
31
What Junit does not do
  • Figure out your tests for you
  • Calculate any coverage criteria
  • Test GUIs
  • Except extensions
  • JFCUnit
  • Jemmy
  • Pounder
  • Abbot

32
Administrative
  • Download latest version (3.7) from
  • www.junit.org
  • Setup classpath to junit.jar
  • Include appropriate ui in main
  • Import junit.framework.

33
Next Time
  • Extreme Programming
Write a Comment
User Comments (0)
About PowerShow.com