DWS Interview Question: What is unit testing? How do ... | Glassdoor

Interview Question

One Out of: Java and .NET (Developer) Or Solution Architect (Not Decided) Interview Melbourne (Australia)

What is unit testing? How do I go about writing a unit

  test? Do I focus a unit test on a class or a method? Would I write one or more tests per method? What are some unit testing frameworks?
unit testing, agile development, test-driven development, design by contract

Interview Answer

1 Answer


Unit testing is automated testing of individual smallest units of program code to see if they fulfill the contract they were written for correctly. (-> Design by contract).

"Smallest units" of program code can be classes or methods.

In .Net, the Visual Studio Unit Testing Framework generates default unit tests for the methods of a class. So, when you have coded the basic design of a class and its methods with their signatures (possibly from a UML class diagram), the tests can be auto-generated and then filled in. By default, there is one test per method; if different input-output relationships of the method have to be tested, this is usually done with different method calls within the one test.

This may work differently with different unit testing frameworks: http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks

In "pure" test-driven development, the test is written even before the class, and the class then written so that the test will compile (and later, when coding is finished, even run without an error).

Interview Candidate on Oct 8, 2012

Add Answers or Comments

To comment on this, Sign In or Sign Up.