testing Flashcards

1
Q

process where developers write automated test cases before writing the actual code for their software.

A

Test-driven development (TDD)

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

In TDD, the development process is broken down into ——–, iterative steps.

A

small

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

First, a ——- is written that describes the ——– behavior of the code to be written. Then, the developer writes the code that ——– the test. If the code passes the test, the developer moves on to the ————-, writing another test for a new behavior, and then writing code to satisfy that test.

A

test
desired
satisfies
next iteration

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

Benefits of TDD
1.Early ——- detection.
2. ——— code quality
3. ———–development time

A

bug
Improved
Reduced

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

testing of the smallest testable units of code (for Java, this will be methods). and ensures that everything is running as it should

A

unit testing

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

Generally, tests can be ———— or ————- tests and you should have both.

A

positive
negative

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

with ———— tests give an we give an expected/valid input and check to see if the expected return occurs.

A

positive

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

with ————- tests we take an invalid/unexpected input and see if your code handles it correctly.

A

negative

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

a testing framework that provides annotations and methods for creating unit tests.

A

JUnit

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

used to record application events, log debugging information for developers, and write exception events to files.

A

What is logging

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

first steps for TDD.
TDD involves writing ——— tests first,
then writing the ———- amount of code necessary to pass the test,
then ———- the code.
finally the process is ————- until all of the desired functionality is implemented.

A

failing
minimum
refactoring
repeated

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

disadvantages of TDD

A

Forget to run tests frequently
Write too many tests at once
Write tests that are too large

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

Do all projects need to be tested before going live? If not, then when should testing be skipped?

A

yes, all projects need to be tested before going live.

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

This is an important part of software development, it allows developers to preserve knowledge that that can be transferred to new developers. it also makes the code base easier to read, understand and maintain, and it’s a reference new developers can look at to understand the codebase and how the code works.

A

what is developer documentation

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

————- coverage is used to test how many lines of code is being executed by tests, and can help highlighting areas of code that are not being adequately covered.

————— coverage is used to make sure that all the aspects of the software is adequately tested and measures the percentage of requirements.

A

code

Test

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

What is more important: code coverage or test coverage? Explain your answer.

A

Both. code coverage and test coverage are important in different ways.

17
Q

Is it necessary to follow each step in the TDD process? What happens if we skip a step?

A

no it is not necessary but skipping a step can lead to bugs and errors that are avoidable.

18
Q

What’s the difference between manual and automated testing?

——– testing involves human testers executing test cases and checking to make sure that the software’s behavior matches the expected behavior

———– testing is done buy a computer
——– testing is good large and complex systems
—– testing is good for making sure the users needs are met by the software.

A

Manual
automatic
automatic
manual

19
Q

What’s the difference between functional and non-functional testing?

————– testing focuses on the functional requirements which is making sure the software works as expected and meets user requirements while

———– testing is used to check the non-functional requirements.

Functional testing typically involves testing the software’s ——- and output, data validation and examples include unit testing and acceptance testing. Non-functional testing typically involves testing the software’s performance, reliability, and accessibility and examples include load testing and security testing.

A

Functional

non-functional

20
Q

Functional testing typically involves testing the software’s ——- and —–, data validation and examples include ——- testing and acceptance testing.

Non-functional testing typically involves testing the software’s ———, reliability, and accessibility and examples include ——– testing and security testing.

A

input
output
unit
performance
load

21
Q

JUnit achieves the isolation of tests through several mechanisms:

————— = methods that set up the test environment before each test case is run.

—————- = classes that execute test cases and report the results.

—————— = used to compare expected and actual results in a test case.

————— = objects that simulate the behavior of a real object, and can be used to test code that depends on that object.

A

Test fixtures
Test runners
Assertion methods
Mock objects

22
Q

How do you check if a test method throws Exception in JUnit?

A

@Test annotation and the assertThrows() method.

23
Q

What are some best practices you follow while writing code to make it more testable?

1).Write ——-, focused methods:
2.)Write code that is easy to ——:
3.) Use ——– to abstract away implementation details.
4.)Write ——– code from the start:

A

small
understand
interfaces
testable

24
Q

What is the difference between Stub and Mock in Unit testing?

——— are simpler and are used to verify the behavior of the class being tested.

———— more complex and a more powerful way to verify the behavior or the class being tested.

——- designed to mimic the behavior of dependencies

———- provide controlled input to the class being tested.

A

stub
mock
mock
stub

25
Q

To test a protected method using JUnit, you can either create a ———- that exposes the method or use ——– to access the method directly.

A

subclass
reflection

26
Q

————— is a feature in Java that allows a program to examine and modify the behavior of objects at runtime.

A

reflection

27
Q

private methods are only accessible within the same class, so you ——– directly test a private method using JUnit.

One approach is to use the ————- annotation to make the private method visible to the test class. This annotation is not part of the standard Java library, but it is provided by some libraries such as Guava.

A

cannot
@VisibleForTesting

28
Q

JUnit test classes should be placed in the same ——- and directory structure as the ——- code classes they are testing.

A

package
package

29
Q

What is the difference between JUnit 4 and JUnit 5?

JUnit5 instroduced assertion methods that are more flexible like the assertAll() method and the assertThrows() method.
JUnit 4 had teests organized in test classes that contained test methods annotateed w/@test
JUnit 5 allowed tests to be organized in nested test classes and allows annotations such as @BeforeEach, and @AfterEach.

A

Programming model: JUnit 4 uses a class-based programming model, where tests are organized in test classes that contain test methods annotated with @Test. JUnit 5 introduces a new programming model that allows tests to be organized in nested test classes, and uses annotations such as @BeforeEach, @AfterEach, @BeforeAll, and @AfterAll to define setup and teardown behavior.

Extensions: JUnit 5 introduces a powerful extension model that allows developers to extend and customize the behavior of the framework. Extensions can be used to add new annotations, modify the test execution order, provide dependency injection, and more. JUnit 4 also supports extensions, but they are more limited in scope.

Platform: JUnit 5 is designed to be more modular and flexible than JUnit 4, and provides a new platform that separates the core framework from the test engine and the IDE integration. This allows developers to use JUnit 5 with different build tools, test runners, and IDEs, and to run tests on different platforms and environments.

Assertions: JUnit 5 introduces a new set of assertion methods that are more expressive and flexible than the ones in JUnit 4. The new assertAll() method allows multiple assertions to be grouped together, and the assertThrows() method provides a convenient way to test for exceptions.