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

97 views4 pages

Document Summary

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. Writing tests to compare all elements of arrays is sometimes slow, annoying, and di cult. Using org. junit is helpful since it has built-in tools to compare arrays. Sometimes task is unclear until you try something. Optional: refactor code to make it faster, cleaner, etc. A complementary approach to unit testing: integration testing. Unit testing is not enough to ensure modules interact properly or that system works as expected. Testing at highest level of abstraction may miss subtle or rare errors. Selection sort the remaining n - 1 items (without touching the front item!) Use import statements and @test annotations to prevent writing main method and org. junit every time for assert statements.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents