How to update the test case result in MTM using C#

Hi
I have tried the following code but when I execute the same I am getting the testcase result as "In Progress".
How to update the testcase execution result as Passed.
I tried the below code:
public
static
void UpdateResult()
TfsTeamProjectCollection tfs =
new
TfsTeamProjectCollection(TfsTeamProjectCollection.GetFullyQualifiedUriForName(server));
ITestManagementService tms = tfs.GetService<ITestManagementService>();
ITestManagementTeamProject proj = tms.GetTeamProject(project);
ITestPlan Plan = proj.TestPlans.Find(1);
ITestRun testRun = proj.TestRuns.Create();
testRun = Plan.CreateTestRun(false);
ITestPointCollection points = Plan.QueryTestPoints("SELECT
* FROM TestPoint");
foreach (ITestPoint
p in points)
testRun.AddTestPoint(p,Plan.Owner);// null);
testRun.State = TestRunState.Completed;
testRun.Save();
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;   
iterationResult.Actions.Add(stepResult);
iterationResult.Outcome = TestOutcome.Passed;
result.Iterations.Add(iterationResult);
result.Save();
results.Save(true);
testRun.Save();
testRun.Refresh();

Hi Mohammed,
Sorry for my delay.
According to your code, I have been modified your code in my side and it can work fine. So you can refer the following code to check your issue in your side.
Reference:
publicstaticvoidUpdateResult()
TfsTeamProjectCollectiontfs
= newTfsTeamProjectCollection(TfsTeamProjectCollection.GetFullyQualifiedUriForName(server));
ITestManagementServicetms
= tfs.GetService<ITestManagementService>();
ITestManagementTeamProjectproj
= tms.GetTeamProject(project);
ITestPlanPlan = proj.TestPlans.Find(1);
IStaticTestSuitesuite
= Plan.RootSuite.SubSuites.Where(s
=> s.Id == 1339).First()
asIStaticTestSuite;
ITestCasetestcase
= null;
testcase
= suite.Entries.Where(e
=> e.Title == "login").First().TestCase;
ITestRuntestRun
= project.TestRuns.Create();
testRun
= Plan.CreateTestRun(false);
ITestPointCollectionpoints
= Plan.QueryTestPoints("SELECT * FROM TestPoint WHERE TestCaseId ="+
testcase.Id);
foreach(ITestPointp
inpoints)
testRun.AddTestPoint(p,
Plan.Owner);// null);
//testRun.AddTestPoint(p, null);
testRun.State =
TestRunState.Completed;
            testRun.Save();
ITestCaseResultCollectionresults
= testRun.QueryResults();
ITestIterationResultiterationResult;
foreach(ITestCaseResultresult
inresults)
                iterationResult = result.CreateIteration(1);
foreach(ITestSteptestStep
inresult.GetTestCase().Actions)
ITestStepResultstepResult
= iterationResult.CreateStepResult(testStep.Id);
                    stepResult.Outcome
= TestOutcome.Passed;   
                    iterationResult.Actions.Add(stepResult);
                iterationResult.Outcome
= TestOutcome.Passed;
result.Iterations.Add(iterationResult);
result.Outcome
= TestOutcome.Passed;
result.State = TestResultState.Completed;
result.Save(true);
testRun.Save();
testRun.Refresh();
Note: you will need to
base on your requirement to modify the code such as modify the testsuite id and title in your side.
In addition, I find a blog about TFS API that can help you:
# Code snippets on Test Management APIs
http://blogs.msdn.com/b/aseemb/archive/2012/08/07/code-snippets-on-test-management-apis.aspx
Best Regards,
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • How to update  the restricted rows that were selcted using fetch

    Hi
    I have to fetch  one row at a time from my staging table using JDBC Sender Adapter,  which is configured against AS400 DB2 and push it to R/3.
    The select  SQL looks like this in JDBC Sender Adapter
         <b>select  jedata, oxruns from fxjrnep2 where oxsts=' '   fetch first 1 rows only</b>
                                       and
    update sql is
         <b>update suplib.FXJRNEP2 set OXSTS='SUC' where OXSTS=' ' </b>
    The problem here is my select gets one row, which is what i want, but my update actually updates all the rows that satisfied the where condition oxsts=' ' instead of one.
      I couldn't  use <b>fetch first 1 rows only</b> at the end of the update sql to update the selected row. DB2 does not allow  fetch in update sql.
    Can anyone suggest solution here or recommend alternative?
    Best Regards
    Venkat

    check for update query where u can club the select stmt u had used with udpate like:
    update suplib.FXJRNEP2 set OXSTS='SUC' where OXSTS = (select jedata, oxruns from fxjrnep2 where oxsts=' ' fetch first 1 rows only
    just need to try combinations of this type.
    if still this is not working use a bpm and get all the records where OXSTS is null and process record one by one within a block

  • How to update the payload of a BPEL process instance

    Hi I have another question.
    How do I update the payload of a BPEL process instance without the activity being a Human Task. I know there are ton's of example showing how to update the payload of a user task using BPEL API's. But in my case I need to update the payload of a BPEL process instance which has no human task.

    Thanks
    For confirming that the payload in the BPEL process instance is read-only. Now I can see what alternatives I come up with besides the DB save option.
    Guys if you can take the time to answer/comment on another question I have posted in this forum that will be great
    here is the link
    Multi step Human Task
    Regards,
    Jayesh Nazre
    MCSD, MCSE, SCJP, PMP

  • How can I execute the test case written excel sheet

    Hello
    I have written the test cases  in excel sheet. Please tell any one how to execute test case from labview.please send some sample vi

    I'm sorry, but you've provided zero information on what you have. All you've said is that you have an Excel "sheet" with test cases, and that it's written in VBA. What does that even mean? What's written in VBA? Are you trying to call the VBA code? Are you trying to rewrite the VBA code in LabVIEW? Unless you provide a better explanation of what you have and what you are trying to do, we can just keep playing a guessing game.

  • How to update the status of Outbound IDOC in case of error

    I want to know about how to update the status of Outbound IDOC in case of error.
    I am using message control functionality here.

    HI,
    If u r using the standard message and basic type
    u can do it in the FM attached to the basic and message type.There u need to write ur own message instead of standard SAP message..chek if there r any userexits available in the FM..where u can overwrite ur own message ..
    If u r using the Zmessage and Zbasic type
    then u need to declare an internal table of EDIDS structure and then append ur message to the internal table..
    idoc_status-docnum   = idoc_contrl-docnum.
      idoc_status-msgty    = <message type>
      idoc_status-msgid    = message-id.
      idoc_status-msgno    = message-number.
      idoc_status-msgv1    = message-message_v1.
      idoc_status-repid    = sy-repid.
      idoc_status-status   = <give the error status>.
      APPEND idoc_status.
    Reward if u find useful
    Regards,
    Nagaraj

  • Where to upload test case results in SAP Solution Manager?

    Hi Experts,
    I am new to test management module in SAP Solution Manager. I need to know where to upload test case results in sap solution manager.
    Please provide screenshots on how to upload test results.
    Regards,
    Sanjana

    Hi Sanjan,
    let me provide you some more information.
    First of all you create a SAP Solution Manager Project in Transaction SOLAR_PROJECT_ADMIN. I think this should be no problem. After creating the Project, make sure that the tap "Test Cases" is switched on in this project. The tap "Test Cases" is the tap below "Project Standards".
    Go to transaction "solar02" and choose your created project. Find the tap "Test Cases" and upload a sample file. Please note that the configuration structure of this project can be configured in solar01 (Business Blueprint). There are many settings you can choose in a project regarding ti your requirements. Try to find them out! :-)
    In transaction Test Plan Management (STWB_2) you can choose all relevant test cases you uploaded in your project and generate Test Packages which are mapped to your choosen Testers.
    In Transaction stwb_work you will see the testers workbench.
    Best regrads
    J.Eichner

  • How to update the BOX version of the Logic Pro 9 in Mountain Lion??

    Hi!
    How to update the BOX version of the Logic Pro 9 in Mountain Lion?
    For example,  if tomorrow will be new updates for Logic Pro for exapmle 9.1.8. (now I have 9.1.7) Will I not able to get it?? Now should I buy the second Logic pro??
    Recently I have got answer from App Store support:
    "Max, since you have not purchased the app in the App Store, you can't get updates directly in App Store. In this case, you will need to purchase the updated version in the App Store so you can get further updates."
    It's... I bought Logic Pro 9 + MainStage +  + +++ .... in the Apple Retail Store and what now?? Updates works perfect in Snow Leopard.
    I can't understand...
    Can you help me please? =)

    Max,
    Rest assurred, you will get updates via the App store. What will happen is when you install the box version, the Mac App Store will ping when there is an update to download(for free), much like any other Apple app(Garageband, iWork, etc) regardless of where you bought it from. If it's installed, it will check for updates.
    If the Mac App store doesn't show an update that you know is out, simply down it directly from support.apple.com and apply it.
    Hope this helps. If so, LIKE the post.
    Glenn

  • Getting TF42008: The test case management package could not be loaded. Verify that Visual Studio Test Tool is installed and try again.

    We are trying to run unit tests in TFS server.
    Below is the System Configuration:
    Visual studio version: VS 2013 Ultimate
    TFS: TFS 2013
    For this we have created a build and able to run the build successfully. And build page showing one link for Test result. When we click on this link, we got below error message.
    "Getting TF42008: The test case management package could not be loaded. Verify that Visual Studio Test Tool is installed and try again."
    And below is the screenshot of the error message. So please let us know is there and thing else we need to do to solve this issue?

    Hi RS, 
    Thanks for your reply.
    Yes, if you want to open and view test result on your laptop, you need install the VS 2013 on your laptop as well.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to do the testing in Oracle SOA suite 11g

    Hi,
    Could any one plz provide the info abt " How to prepare the Test Suite(Test cases) in oracle soa 10g/11g ". Information provided that is been related to real time scenarios is much appreciated.
    Thanks in advance,
    Venu

    Hi,
    Check whether this doc:
    http://docs.oracle.com/cd/E21764_01/integration.1111/e10224/bp_testsuite.htm
    and this blog can help you:
    http://biemond.blogspot.com/2009/07/unit-test-your-composite-application.html
    hth,
    Peter Paul

  • How to get the sql query result?

    Hi,
    Currently I am using LV2012 to connect a Oracle database server. After the installations/settings for Oracle Express and Oracle ODBC driver done.
    I am sucessfully to use the SQL command to query the data through my window command prompt. 
    Now the problem is, how I do the same task in Labview by using the database connectivity toolkits?
    I have build a VI for query as attached, but i have no idea what pallete to use to get the query result.
    Please help me ~~
    Solved!
    Go to Solution.
    Attachments:
    Query.vi ‏9 KB

    Here is a piece of code I use to test SQL commands, you can use the part that retrieves sql results.
    It is also possible to get the column headers back, but that is for next lesson!
    Attachments:
    RunSQLCommand.vi ‏30 KB

  • How to update the merged customer information in custom tables?

    The "Setup merge Dictionary" is provided only to register APIs that would be called to update the merged information for parties.
    Is there a similar feature for the account merge?
    If anyone has any ideas of how to update the columns like customer_id, cust_acct_site_id etc. in custom tables at the end of customer merge, please let me know. Any sample code would be of great help.
    Please let me know ASAP.
    Thanks in advance,

    There is one method which I have used. The crm side uses a file called jtf_hooks_data. There is no guarantee that it will work in the future and you will have to test it. The merge program uses this sql
    'SELECT hook_package, hook_api,product_code ' ||
    'FROM jtf_hooks_data '||
    'WHERE package_name = ''ARP_CMERGE_MASTER'' ' ||
    'AND api_name = ''MERGE_PRODUCTS'' ' ||
    'AND execute_flag = ''Y'' ' ||
    'ORDER BY execution_order ';
    Your procedures have to have the same signature as the one being called. Issues the select statement on your system and see what is returned.

  • How to insert the select query result into table?

    How to insert the select query result into table?
    SELECT  top 20 creation_time  
            ,last_execution_time 
            ,total_physical_reads
            ,total_logical_reads  
            ,total_logical_writes
            , execution_count 
            , total_worker_time
            , total_elapsed_time 
            , total_elapsed_time / execution_count avg_elapsed_time
            ,SUBSTRING(st.text, (qs.statement_start_offset/2) + 1,
             ((CASE statement_end_offset 
              WHEN -1 THEN DATALENGTH(st.text)
              ELSE qs.statement_end_offset END 
                - qs.statement_start_offset)/2) + 1) AS statement_text
    FROM sys.dm_exec_query_stats AS qs
    CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) st
    ORDER BY total_elapsed_time / execution_count DESC;
    Thanks,
    Tirumala

    1. SELECT INTO
    Below method will create table when data is inserted from one table to another table. Its useful when you need exactly same datatype as source table.
    Use AdventureWorks2008R2;
    Go
    ---Insert data using SELECT INTO
    SELECT AddressLine1, City
    INTO BothellAddresses
    FROM Person.Address
    where City = 'Bothell';
    GO
    ---VERIFY DATA
    Select AddressLine1, City
    FROM BothellAddresses
    ---DROP TABLE
    DROP TABLE BothellAddresses
    GO
    2. INSERT INTO SELECT
    Below method will need table to be created prior to inserting data. Its really useful when table is already created and you want insert data from
    another table.
    Use AdventureWorks2008R2;
    Go
    ---Create Table
    CREATE TABLE BothellAddresses (AddressLine1 NVARCHAR(60), City NVARCHAR(30))
    ---Insert into above table using SELECT
    INSERT INTO BothellAddresses(AddressLine1, City)
    SELECT AddressLine1, City
    FROM Person.Address
    where City = 'Bothell';
    ---VERIFY DATA
    Select AddressLine1, City
    FROM BothellAddresses
    ---DROP TABLE
    DROP TABLE BothellAddresses
    GO
    Regards,
    Vishal Patel
    Blog: http://vspatel.co.uk
    Site: http://lehrity.com

  • How to update the recorded scripts as per the new interface

    Hi,
    I am using E-tester 8.20 and generating the scripts by record and playback. Here my problem is how to update the scripts when new version of user interface (UI) comes. For example, page1 of UI has recorded with 5 text boxes. In the new version of UI, one more text box (6th text box) has been added and that is mandatory filed. So I have to update my scripts as per the new interface to enter a value in the 6th text box. Is there any way to do it? Any kind of help should be appreciated.
    Regards,
    Vinod

    Hi
    Are you talking functional or load scripts?
    Regards
    Alex

  • [svn] 3822: update the test to use qa-regress axis web service target

    Revision: 3822
    Author: [email protected]
    Date: 2008-10-22 11:53:21 -0700 (Wed, 22 Oct 2008)
    Log Message:
    update the test to use qa-regress axis web service target
    Modified Paths:
    blazeds/branches/3.0.x/qa/apps/qa-manual/ipv6/proxyservice/webService/ipv6_ws_dynamicurl. mxml

    I solved that url problem. But there is still something I need to ask.
    First of all, the solution is the following;
         I have implemented my asp.net web service with visual studio, creating web service application. when I implement the project, it shows how to send requests( soap, http ), and there is http post request.( no get ). then I create and http post service with flash builder, the problem was that I needed to add a submit parameter to that service call since this is a post request to asp.net( Content-Type: application/x-www-form-urlencoded ). when I add this parameter it works well.
         however I want my service to return xml directly. In a different post http://forums.adobe.com/thread/574684?tstart=0 the problem is solved for PHP http requests. but when I try to implement in the same way it gives following error:
    any solution for that? thx

  • How to update the table value in the valuechange event?

    I have an input field in the datatable with the valueChangeListener
    <rich:dataTable id="cart" value="#{cart.cartList}" var="item">
    <h:inputText value="#{item.cost}" id="qty" valueChangeListener="#{items.updateCost}" onchange="submit()">
    <h:outputText value="#{item.errorMsg}"> </h:outputText>
    in the backing bean
         Item item = (Item) model.getRowData();
    // do some update, if the cost too larger, change to max_cost
         item.setCost(max_cost);
         item.setErrorMsg("Error Msg");
    After calling the valuechange method, the screen output doesn't update the cost.
    How to update the table value in the valuechange event?

    As you're misusing the valueChangeListener to set another input field, you need to skip the update model values phase. Otherwise the value set in the valueChangeListener will be overridden by the submitted value. You can do this by calling the FacesContext#renderResponse() inside the valueChangeListener method. This will shift the current phase immediately to the render response phase, hereby skipping the update model values and invoke application phases.

Maybe you are looking for