Testing/XML Flashcards
Why unit test?
The main goal of the unit testing is to verify the correctness of a software unit by comparing the return value of a unit with the expected result for a different set of parameter values.
What is a software unit? (3)
- smallest testable part of an application
- in procedural programming, it is a function or procedure
- in Object-Oriented programming, it is a member function or method
What are unit tests? (4)
- each unit test tests executes a test case
- units are tested independently of each other
- multiple test cases per unit (one per equivalence class)
- tedious to run all tests by hand –should be automated
What are the benefits of unit testing? (3)
- facilitates change -automatically see if new changes break compilation
- implicit documentation -see how the code is actually used
- enforces interface/implementation split
Why do you refactor code for testable code design? (4)
- to simplify code structure and its readability
- usually involves extracting complex code into a number of well-named methods
- does not necessarily shorten the code
- should make individual sections of the code easier to read and maintain
Refactor the following code to make it more legible.
private void button1_Click(object sender, EventArgs e)
{
int num1 = int.Parse(textBox1.Text);
int num2 = int.Parse(textBox2.Text);
int total = num1 + num2;
label1.Text = total.ToString();
}
private void button1_Click(object sender, EventArgs e)
{
int num1 = int.Parse(textBox1.Text);
int num2 = int.Parse(textBox2.Text);
int total = FindTotal(num1, num2);
label1.Text = total.ToString();
}
private int FindTotal(int num1, int num2)
{
int total = num1 + num2;
return total;
}
What are the testing frameworks for C++?
- Boost.Testinglibrary
- CPPUnit
- CxxUnit
What are the testing frameworks for NET languages?
- Nunit
- xUnit.net
- MbUnit
- QuickUnit.net
- csUnit
What is the testing framework for Java?
Junit
List the Visual Studio 2012 test tools. (4)
- Test Explorer
- Microsoft unit test framework for managed code and C++
- Code coverage tools
- Microsoft Fakes isolation framework
What does the Test Explorer in Visual Studio do?
It lets you run unit tests and view their results.
What does the Microsoft unit test framework for managed code and C++ do?
It provides a framework for testing .NET code and native code.
What do Code coverage tools do?
They determine the amount of product code that your unit tests exercise.
What does the Microsoft Fakes isolation framework do?
It creates substitute classes and methods for the code under test.
All the methods and classes generated for the automated unit testing are inherited from the namespace …
Microsoft.VisualStudio.TestTools.UnitTesting