Definition/Design Principles Flashcards

1
Q

When it’s not necessary to use TDD? ( 6 options )

A

1) Acceptance tests ( like capybara when we have interaction with browser )
2) Spike ( when you’re just investigated and don’t write production code)
3) Uknown Output ( when you’re not sure about the output)
4) The entire program is small or unlikely to change. If it’s small enough to test by hand efficiently, you may elect to forego testing.
5) The program will only be used for a short time.
6) You don’t care if the program doesn’t behave as expected. If the program is unimportant, it may not be worth testing.

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

Do you know any important prescriptions for writing tests?

A

1) When possible, write your tests to describe your
code’s behavior, not its implementation.
2) It’s usually better to have the implementation code be as independent as possible from the test itself.
3) Avoid complex metaprogramming or loops in test code that might make it challenging to understand and evaluate test failure.
4) Expectations that cover different branches of the
application logic should be handled in separate
specs.

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

What is the main goal of good testing?

A

The goal of testing is to minimize the cost of

doing testing and maximize the value.

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

What kind of test cost do you know? ( 4 )

A

WRUF

  • The time it takes to write the test
  • The time it takes to run the test every time the suite runs
  • The time it takes to understand the test
  • The time it takes to fix the test if it breaks and the root code is okay
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the most important Qualities of Valuable Tests do you know? ( 5)

A

SWIFT

  • Straightforward/Clear ( Keep your test as simple as possible )
  • Well Defined/Permanent ( Every time you run your spec you get the same result )
  • Independent ( A test is independent if it doesn’t depend on any other tests or external data to run.)
  • Fast
  • Truthful ( It breaks when code breaks and vise Versa )
  • Maintainable ( It is easy to add new tests and existing tests are easy to change )
  • Expressive ( They should be easy enough to read so they can serve as said documentation. )
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Why we should use the factory instead of creating ActiveRecord object?

A

Because in the future ActiveRecord creation can become much more complex ( new authentication, callbacks etc) and then won’t be easy to test direct behavior. It would be easier to move full prepared object to another abstraction.

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