Test-Driven Development Flashcards
1
Q
What is testing?
A
Executing a program with the intention of finding errors in the code
2
Q
What are the stages of the Waterfall model? (6)
A
- Analysis
- Specification
- Design
- Implementation
- Testing
- Operation & Maintenance
3
Q
What are the problems of the Waterfall model? (4)
A
- Testing happens late, if at all
- Requirements decoupled from code during development
- Quality is someone else’s problem (SEP)
- Hard work to test, so not all problems are identified
4
Q
What is Test-Driven Development (TDD)? (3)
A
- Identify a feature to be implemented and write an initially failing automated test case for it
- Write code to pass the test
- Run the test again and previous tests if any and repeat
5
Q
What is TDD a good approach to development? (2)
A
- Making small improvements frequently ensures having a working system at all times
- System is less volatile to modifications when they are small and incremental
6
Q
What does the concept of YAGNI mean?
A
Don’t build stuff because it might be useful, and keep code as simple as it can be
7
Q
What elements should a unit test have? (4)
A
- Focused, testing one thing at a time
- Fast to run
- Independent of each other, run order and the environment
- Automatic
8
Q
What is the coverage of unit tests? (3)
A
- Every method tested
- Every statement tested
- Every branch tested
9
Q
What are the test cases for a method that sorts an array of integers? (7)
A
- Array is null
- Array has zero length
- Array has one length
- All elements are the same
- Some elements are null
- Array is already sorted
- Array is reverse sorted
10
Q
What is the control flow for unit testing? (4)
A
- New instance of test class created for every test
- Create objects needed for the test
- Establish state for start of the test
- Tidy up if necessary
11
Q
What is the control flow for a unit test in terms of Java annotations? (5)
A
@BeforeClass @Before @Test @After @AfterClass