Testing/XML Flashcards

1
Q

Why unit test?

A

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.

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

What is a software unit? (3)

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are unit tests? (4)

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the benefits of unit testing? (3)

A
  • facilitates change -automatically see if new changes break compilation
  • implicit documentation -see how the code is actually used
  • enforces interface/implementation split
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Why do you refactor code for testable code design? (4)

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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();
}

A

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;
}

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

What are the testing frameworks for C++?

A
  • Boost.Testinglibrary
  • CPPUnit
  • CxxUnit
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the testing frameworks for NET languages?

A
  • Nunit
  • xUnit.net
  • MbUnit
  • QuickUnit.net
  • csUnit
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the testing framework for Java?

A

Junit

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

List the Visual Studio 2012 test tools. (4)

A
  • Test Explorer
  • Microsoft unit test framework for managed code and C++
  • Code coverage tools
  • Microsoft Fakes isolation framework
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does the Test Explorer in Visual Studio do?

A

It lets you run unit tests and view their results.

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

What does the Microsoft unit test framework for managed code and C++ do?

A

It provides a framework for testing .NET code and native code.

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

What do Code coverage tools do?

A

They determine the amount of product code that your unit tests exercise.

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

What does the Microsoft Fakes isolation framework do?

A

It creates substitute classes and methods for the code under test.

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

All the methods and classes generated for the automated unit testing are inherited from the namespace …

A

Microsoft.VisualStudio.TestTools.UnitTesting

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

What are the general steps to take in unit testing? (4)

A
  • Create a unit test project
  • Add a reference to the code project under test
  • Write the test
  • Build and run the test
17
Q

•The AAA (…) pattern is a common way of … for a method under test.

A

Arrange, Act, Assert

writing unit tests

18
Q

What happens at the Arrange stage of unit testing?

A

It initializes objects and sets the value of the data that is passed to the method under test.

19
Q

What happens at the Act stage of unit testing?

A

The Act section invokes the method under test with the arranged parameters.

20
Q

What happens at the Assert stage of unit testing?

A

The Assert section verifies that the action of the method under test behaves as expected.

21
Q

What do Test Explorer views do?

A
  • display all of your tests, or only the tests that have passed, failed, haven’t been run yet, or have been skipped
  • filter the tests by matching text in the search box at the global level or by selecting one of the pre-defined filters
  • run any selection of the tests at any time
22
Q

kk

A

[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.