Lecture 5-Test for inheritance and testing patterns Flashcards

1
Q

What are 2 examples of inheritance-related bugs?

A

1.Missing override
2.Direct access to superclass fields from the subclass code

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

What is the objective of testing inheritance?

A

Inherited methods should be retested in the context of a subclass.
ex: if we change method m in superclass, we need to retest m inside all subclasses that inherit it.

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

What is the Liskov Substituion principle (LSP)?

A

Functions that use references to base classes must be able to use objects of derived classes without knowing it.

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

What are the effects of inheritance on testing (2)?

A

1.It does not reduce the volume of test cases.
2.Number of interactions to be verified goes up at each level of the hierarchy.

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

Why do we test abstract classes?

A

For functional compliance

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

What is functional compliance?

A

It’s a module compliance with some documented or published functional specification.

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

Functional vs syntactic compliance

A

For syntactic :
-The compiler can easily test that a class is syntactically compliant to an interface–> all methods in interface must be implemented with the correct signature.

Its tougher for functional compliance…

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

What does the abstract test pattern provide(2)?

A

-A way to build a test that can be reused across descendants.
-A test suite that can be reused for future for unidentified descendants ( useful for APIs)

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

What is the first rule of abstract test?

A

Write an abstract test class for every instance and abstract class.

*should have test cases that cannot be overriden + an abstract factory method for creating instances of the class to be tested.

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

What is the second rule of abstract test?

A

Write a concrete test class for every implementation of the interface

*should extend the abstract test class and implement the factory method.

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

Let’s make it simple: How do I know if abstract or concrete?

A

Test defining the functionality of the interface–> ABSTRACT

Test specific to an implementation –>CONCRETE

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

Why do we use a crash test dummy?

A

It can be hard to create a situation that will cause the error–> so we fake it!

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

What are 2 examples of test smells?

A

1.Eager test
2.Lazy test

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

When do we use an eager test?

A

When a test method checks several methods of the object to be tested and becomes hard to read and understand.

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

What does the eager test do?

A

Separates the test code into test methods that test only one method, using a meaningful name highlighting the purpose of the test.

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

What is the downside of eager test?

A

Splitting into smaller methods can slow down the tests due to increased setup/teardown overhead.

17
Q

When do we use lazy tests?

A

When several test methods check the same method using the same fixture.