Testing Flashcards

1
Q

Why is automatic testing better than manual testing?

A
  • takes less time
  • can be run again and again
  • useful for big projects with multiple developers working on them
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the types of tests that exist?

A
  • unit
  • integration
  • system
  • acceptance
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

For what part is unit testing done?

A

Tests specific code sections; each test is for a specific unit of code(small)
Detailed Design

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

For what is integration testing done?

A

It tests whether the components work properly together; for complex integration with external services
Architectural Design

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

What is system testing used for?

A

It tests complete, real program flows

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

What is acceptance testing used for?

A

It tests whether the program fulfils the requirements; usually done with/by the customer
Requirements definition

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

What is the reglementation used for a coding project and what does it mean?

A

SPICE - Software Process Improvement and Capability dEtermination(top-down design and bottom-up testing)

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

What does top-down design mean?

A
  1. Requirements
  2. Architectural Design
  3. Detailed design
  4. Coding
  5. Configuration
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does bottom-up testing mean?

A
  1. Configuration
  2. Testing Data Preparation
  3. Unit
  4. Integration
  5. Acceptance
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the stages of TDD?

A
  1. Design
  2. Writing Tests
  3. Writing code
  4. Refactoring
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is TDD?

A

Test Driven Development; the concept of defining a method’s specifications through assertions in a test before implementing the method itself.

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

Why choose TDD?

A
  • tests take time
  • they are boring
  • less testing if they are left right before the deadline
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Should the stages of TDD be done by the same person/team?

A

No, most stages should be carried out by separate teams so that the people writing the tests would have no knowledge of the implementation. This way, they can test everything from the perspective of the client and be more thorough.

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

What is JUnit?

A

A testing framework that can be used for automatic unit testing. The test files are simple classes that make use of annotations and assertions to perform the tests.

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

What are annotations?

A

They are structures added above a method to augment its behavior. (@Test, @BeforeEach, @AfterAll etc)

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

What are assertions?

A

Statements that verify certain characteristics of the code(for boolean true or false, if an object is null or not, if two values are equal or not, if two objects are the same or not etc)

17
Q

When using assertSame or assertEquals what represent the first and second values?

A

First value is the expected one and the second is the actual one.

18
Q

What are some good practices of testing?

A
  • aim for one assert per test(enforce every test to test a different case)
  • unit tests should be indepenedent
  • tests should not interfere with one another
  • passing tests should not be producing any output, but failing ones should
  • when you find a bug not included in the tests, try to test it, because it might not be the cause you believe it to be
19
Q

What to test?

A
  • public/protected instances
  • constructor
  • getters and setters only if the have additional logic
  • test also what a method should not do
  • edge cases
20
Q

What happens when two methods depend on each other from the testing point of view?

A

This is called circular dependency and it should be prevented as much as possible. In cases where this cannot be done, the methods should be tested in a single test method.

21
Q

What does refactoring mean?

A

Refactoring code means making changes
in the code that improve readability, structure, efficiency, flexibility and maintainability without changing the functionality.

22
Q

What are some advantages of refactoring?

A
  • Code will become more readable.
  • Code will become more efficient.
  • Code will become easier maintainable.
  • Code will become more flexible.
23
Q

What are code smells?

A

Code smells are generally the result of bad coding practices.

24
Q

what are some examples of code smells?

A
  • Code duplication
  • Contrived complexity
  • Long methods
  • Data clumps
  • Many methods needed from another class
  • Code in comments
  • Comments in methods
  • Long list of parameters
  • Switch construction for type checking
  • Large classes
  • Un-encapsulated fields
  • Undescriptive naming
  • Inconsistent naming
  • Dead code
  • Middle man
  • Solution sprawl
25
Q

How should you refactor code?

A
  1. Make a small change in your code (a single refactoring)
  2. Run all tests to ensure everything still works
  3. If so, move to the next refactoring
  4. If the tests do not pass, fix the newly created problem (or simply undo the change if the former is impossible).