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)
What are unit tests? (4)
What are the benefits of unit testing? (3)
Why do you refactor code for testable code design? (4)
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++?
What are the testing frameworks for NET languages?
What is the testing framework for Java?
Junit
List the Visual Studio 2012 test tools. (4)
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
What are the general steps to take in unit testing? (4)
•The AAA (…) pattern is a common way of … for a method under test.
Arrange, Act, Assert
writing unit tests
What happens at the Arrange stage of unit testing?
It initializes objects and sets the value of the data that is passed to the method under test.
What happens at the Act stage of unit testing?
The Act section invokes the method under test with the arranged parameters.
What happens at the Assert stage of unit testing?
The Assert section verifies that the action of the method under test behaves as expected.
What do Test Explorer views do?
kk
[TestMethod()]is required in the Microsoft unit testing framework for managed code for any class that contains unit test methods that you want to run in Test Explorer.