12 martie 2012 18:07
The situation is actually quite simple. I have a bunch of old test results (in TRX format) but no test binaries. These were easily imported into TFS using MSTest.exe command line. However, the results as queried via SQL and the TFS_warehouse do not have assigned test cases, suites, or plans.
Ok, so I make a bunch of test plans and test suites. Now I need to take the existing results and align them to these suites/plans, adding the appropriate test cases as I go. I've found how to create test cases programmatically, but what I haven't found is a way to assign results to those test cases where the results are already in the database. All the important fields (such as TestCaseId on an ITestCaseResult object are read-only).
Rerunning these tests isn't the answer, as the results represent historical outcomes over the course of a year which were never imported into TFS. The test binaries no longer exist for those builds either, so I cannot use TCM.exe to import the test cases from the test binaries. I'm not about to hand-create 1000s of test cases.
So, what is the correct way to do this using the currently available TFS, MTM (etc.) APIs so the backend database stays happy?
14 martie 2012 09:17Moderator
Thank you for your post.
According to your description of the issue, I suppose you have used mstest publish command publish test result to tfs database, now you want to associate these test results with corresponding test cases in MTM. If I have misunderstood anything, please free feel to let me know.
As far as we know, if the test associated to a build, it cannot associate to a test case again.
If anything is unclear, please free feel to let me know.
Lily Wu [MSFT]
MSDN Community Support | Feedback to us
14 martie 2012 13:21Yep, you've got it right.
22 martie 2012 02:13
I think if a test associated to a build, it cannot associate to a test case again too.
26 martie 2012 18:25
I've come up with a work around that is less than optimal - basically creating new test results programmatically and copying the corresponsing test result data from the existing MSTest-published results one at a time to the new test result.
In order to do this, I needed to create test cases via code which were then aligned to a particular test plan / test suite. Once that step was done, I needed to generate a test run for each suite (which is really a misnomer, because it doesn't really "run" anything) then fill in the results of the run with the pre-existing results data (including test case implementation construct). Overall, doing all of this in code just so the data would show up nice and clean in the TFS warehouse was appallingly complex.
Would have been so much easier if the test case Id, test plan Id, and test suite Id fields of an existing Test Result were read/write (they are all zero for MSTest-imported TRXs) -- most of these were already known before I ever started in this endeavor...