Unit Testing interview questions and answers

1) How many types of tests run on application?

1)Manual testing
2)Automated testing 

Above both are run by QA

3) Unit testing 
4) Integration testing

Above both are developed and run by developer

5) Acceptance testing

Above run by customer

2) Who will run unit test cases?

Test runner will run automate d unit test cases

Test runnaer will maintain all the info either success or fail it will maintain that data

3)Example for test class and test methods in c#.net?

Namespace Test
{
[TestClass]
public class Test
{
[TestMethod]
public void AddTest()
{
var sum= new Calc().Add(1,2);
Assert. AreEqual(1+2,sum);
}
}
}

4)Controller testing example ?

[TestClass]
public class CtrlTest
{
[TestMethod]
public void WhatReturnFromView()
{
var controller = new HomeController();
 var result = controller. Index();
Assert. IsInstanceOfType(result,type of(ViewResult));
}
}

5) What is TestIntialize attribute?

Using this we initialize object's of test class.

It is called before every test run test class.

6)What is TestcleanUp attribute ?

It is called after every test run in test class.

7)What is different paths in UnitTesting? 

The happy path: arguments with expected values provided 
The error path: Passed invalid arguments 
Edge cases: With provided arguments getting edge of expected values  

No comments:

Post a Comment