These are my sanity-check questions. They are not complicated or long-winded, just simple questions to verify if the content was understood. Some questions also served as a base for further discussion. The developers in the audience were exposed to TDD for the very first time, so I kept them simple. If you are a seasoned developer I am sure these questions will not challenge you at all.
Unit Testing with JUnit
- What is a test fixture?
- Which assert is used to compare the values of objects?
- What about
assertTrue(true);
? - What about
assertTrue(a.equals(b));
? - How to test for an expected exception?
- What about
System.out.println(...);
in tests? - How to data-drive tests?
- How to time-out tests?
- How to test the contents of a private field? (This is a trap, the answer is not to test it but to change the design.)
- Does full code coverage mean the code is fully tested?
- What are the benefits of using TDD?
- Is TDD primarily a testing technique?
- When do you write tests? (This is a joke and the expected answer is "all the f*cking time" according to Bryan Liles' TATFT.)
- What should you do when you cannot add another test?
- If the code passes all the unit tests why should you still change (refactor) it?
- Why not refactor on a red bar?
- Why use stubs or mocks?
- How are objects called that are passed around but never actually used?
- How are objects called that can return fixed values in answer to calls made.
- How are objects called that can verify the behaviour of the system under test, in addition to using asserts to verify its state.
- What is used for testing state?
- What is used for testing behaviour?
- What is a spy?
- What is your favourite Refactoring?
- How do we refactor? (This is a word play and the expected answer is mercilessly.)
- Should Refactoring and adding new code be done at the same time?
- During Refactoring, how long does your code not compile?
- During Refactoring, when should we run the tests?
- What Refactoring can be used when a method is too long, has duplicated code or Feature Envy?
- What Refactoring can be applied to long parameter lists?
- In Eclipse, what do the short-cuts
Alt-Shift-R
,Alt-Shift-L
andAlt-Shift-M
do?
- What is Legacy Code?
- How can you break dependencies?
- What are Singletons and why are they evil?
- Do you write them?
1 comment:
Hi Peter, i've written an answer to your article/questions. Check and correct them under http://www.nullpointer.at/2013/06/26/tdd-exam-question-answers/ if you want to.
Best wishes
Thomas
Post a Comment