Test-Driven Development Flashcards

1
Q

What is testing?

A

Executing a program with the intention of finding errors in the code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the stages of the Waterfall model? (6)

A
  • Analysis
  • Specification
  • Design
  • Implementation
  • Testing
  • Operation & Maintenance
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the coverage of unit tests? (3)

A
  • Every method tested
  • Every statement tested
  • Every branch tested
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the control flow for a unit test in terms of Java annotations? (5)

A
@BeforeClass
@Before
@Test
@After
@AfterClass
How well did you know this?
1
Not at all
2
3
4
5
Perfectly