COMPSCI 61B Lecture Notes - Lecture 7: Junit, Unit Testing, Selection Sort

85 views4 pages
6 Feb 2017
School
Professor

For unlimited access to Class Notes, a Class+ subscription is required.

Lecture 7 (02/01/2017)
Goal for Lecture:
Suppose we want to write a class Sort that prints sorted command line arguments:
Sort will have following methods:
static void sort(String[] a): sorts an array of strings
static void print(String[] a): prints an array of strings
static void main(String[] args): prints the args in sorted order
We’ll write Sort.sort along with testing it
New Method of Testing:
Writing testSort BEFORE we even write sort
Example Unit Test:
Writing tests to compare all elements of arrays is sometimes slow, annoying, and
dicult
Using org.junit is helpful since it has built-in tools to compare arrays
Unlock document

This preview shows page 1 of the document.
Unlock all 4 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+
$10 USD/m
Billed $120 USD annually
Homework Help
Class Notes
Textbook Notes
40 Verified Answers
Study Guides
1 Booster Class
Class+
$8 USD/m
Billed $96 USD annually
Homework Help
Class Notes
Textbook Notes
30 Verified Answers
Study Guides
1 Booster Class