Wednesday, June 26, 2013

SQL Server Interesting Fact

Just try out this

DECLARE @ AS INT
SET @= 6
PRINT @

What you think by looking code?
Isn't it throw an error....but
that's true internally '@' is treated as variable so it will show you output as normal variable.
Just try it..

Add attachment to Test Case Result using TFS API

We can add attachment to test case result using TFS APIs. Here is small code snippet I have created.

ITestRun testRun = _plan.CreateTestRun(false);
ITestCaseResultCollection results = testRun.QueryResults();
ITestIterationResult iterationResult;
 
foreach (ITestCaseResult result in results)
{
     result.Attachments.Add(new Attachment("FileName", "Comments if any"));
}
 
results.Save(true);
testRun.Save();
testRun.Refresh();

Create Test Case Step Result using TFS API

We can create test case step result using TFS APIs. Here is small code snippet I have created.

ITestRun testRun = _plan.CreateTestRun(false);
ITestCaseResultCollection results = testRun.QueryResults();
ITestIterationResult iterationResult;
 
foreach (ITestCaseResult result in results)
{
    iterationResult = result.CreateIteration(1);   
    foreach (ITestStep testStep in result.GetTestCase().Actions)   
   {      
       ITestStepResult stepResult = iterationResult.CreateStepResult(testStep.Id);      
       stepResult.Outcome = TestOutcome.Passed; //you can assign different states here
       iterationResult.Actions.Add(stepResult);   
   }   
   iterationResult.Outcome = TestOutcome.Passed;   
   result.Iterations.Add(iterationResult);
}
 
results.Save(true);
testRun.Save();
testRun.Refresh();

Making changes to Child Test suite 'State' will affect the Test plan 'State'?

This question confuses many of us who use MTM for test case management. Curious how state of Test Plan , Test Suite works? Making changes to Child Test suite 'State' will affect the Test plan 'State'?

Answer is No. Changes to Child Test suite 'State' won't affect the Test plan 'State'. Test Plan contain one or more different test suites.
State of Test Plan are:
Active: If Test Plan is set to active which mean that you can run test cases from child test suites of test plan.
Inactive: If it is inactive then you cannot run test from its test suites. you can only view, edit test suites.
And yes State of Test Plan do affects its child test suites. 

State of Test Suite are:
In Planning: Test Suite is not ready to run
In Progress: Test Suite is ready for use/execution
Completed: Test Suite execution completed

Test Suite states won't affect Test Plan. Test Suite state should be In Progress to run test from it.
If you delete Test Plan then it will delete all its test suites and test results so its always better to change Test Plan state to Inactive.

Hope this help you.

How to use TFS solutions and working with source control

Many team/people face issues while working TFS project solutions. How to check in, checkout and get latest and so on. There are basic and main steps to take care of:

Make sure solution checked in properly. you can confirm this with 'View Pending Changes' option. Also all solution files/projects should be bound to source control. All other users should always get solution/projects from TFS only. I mean always use get latest before you start working on any file.

1. Go to same or some other machine OS
2. Open VSTS and Connect to TFS Team Server
3. Double click Source Control option and select your solution folder
4. Map it to local folder. This will prompt you if you want to get it from TFS server. Say Yes
5. And you should be good here.

When you add your solution to source control first  time, VSTS asks to choose checkout policies or you can configure it later.
If you want your team to work on same solution, I mean same file can be shared among different users then follow the steps as -
1. Add solution to source control
2. Check In entire solution
3. Go to Team -> Team Project Settings -> Source Control
4. Enable Multiple check out so that multiple user can use same file
5. Enable get latest on check out so that users will get latest version as and when they check out the file.

Please add comments if you need more details regarding same.