Testing & Debugging Flashcards

1
Q

Unit testing

A

A level of software testing where individual units are tested. (i.e. Testing a method by itself, isolated from the remainder of the program.) The hope is that once the individual pieces are tested and verified to be working, then the likelihood of the overall project working becomes much higher. For Java programs, a unit is usually a method.

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

Test coverage / Code coverage

A

A measure of the amount of source code that has been executed during testing, typically provided as a percentage of lines covered. When executing the set of tests, if any line of code is executed, that line is said to be covered. You can use a tool like EclEmma to measure this.

General practice is to strive for at least 80 percent coverage (higher is obviously better), but remember that 100 percent coverage does not mean that you have handled all possible test cases! It is not uncommon to have more than one test to cover a given unit. That is, it is possible, and is often recommended, to have tests that account for both expected and unexpected behaviour of a given unit.

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

Black-box testing

A

Testing a method without knowing its implementation.

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

White-box testing

A

Testing methods by taking their implementations into account, in contrast to black-box test ing; for example, by selecting boundary test cases and ensuring that all branches of the code are covered by some test case.

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

Boundary test cases

A

A test case involving values that are at the outer boundary of the set of legal values. For example, if a method is expected to work for all nonnegative integers, then 0 is a boundary test case.

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

Trace messages

A

A message that is printed during a program run for debugging purposes.

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

Test data

A

Input to test the program

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

Test driven development (TDD)

A

A programming practice in which tests are written before actual code is written. The goal of the programmer then becomes that of ensuring that they write code such that all the tests pass.

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

Assertion

A

A claim that a certain condition holds in a particular program location.

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

Assert statement

A

A statement wherein the developer is asserting that something needs to be true. Usually, if the assertion fails, code execution is halted. In the context of JUnit testing, built-in assertion mechanisms are provided by the Assertions class.

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

assertEquals

A

An inbuilt assertion used for asserting that the actual value of a variable (or the value returned by invoking a method) matches the expected value. Most unit tests will use this statement extensively.

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

In a JUnit class, what is the annotation for a test?

A

@Test

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

What is the proper syntax for a test that checks equality between a and b?

A

assertEquals(a, b);

* Note that additional parameters, such as an error message or a tolerance, can also be provided.

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

Debugging

A

The process of trouble-shooting errors in your code

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

What is the general process to debug code?

A
  1. Place a breakpoint
  2. Run the code in debug mode
  3. Use the “Variables View” in Eclipse to review the changes to variable values as the code is executed to see where the results being returned are unexpected
  4. Stop debugging when you think you’ve found the issue
  5. Edit your code and change the breakpoint location, if needed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Breakpoint

A

A point in the code where execution will be paused

17
Q

Stacktrace

A

The sequence of method calls that led to the current state

18
Q

Step-into

A

When paused at a breakpoint during the course of debugging, use Step-into to go into the method that is being invoked at that breakpoint.

19
Q

Step-over

A

Step-over is the same as step-into, except that when it reaches a call for another method, it will not step into the method.