<commit_before># SOAtestToMTM

This is an open source example to show how to take a Parasoft SOAtest report.xml and the import test results into Microsoft Test Manager.

This solution includes two projects:

A `SOAtestParser` example to show how to parse SOAtest reports. 
An `MTMImporter` to take the results and send to Team Foundation Server.  

## Prerequisites

This example supports 
* SOAtest 9.8 
* Team Foundation Sever (version )
* Visual Studio 2013, 2015

SOAtest and MTM must be set up correctly with the same assocation structure.

###### Disclaimer
The format of SOAtest reports may be in future updates and how to parse the report will need to be adjusted.

### SOAtest
User must configure the root Test Suite in a tst file with the correct Requirement information that corresponds to the Test Plan sturcture in MTM.

!(/images/requirement.jpg)

In Requirement and Notes tab of each Test Suite, add the association for each test. Association added for each Test Suite will be inherited by its children.

@req is representing a Test Run
@pr is representing a Test Case

The test results correlated in the following logic:
In each test run (associated with @req) can contain multiple test cases (associated with @pr), each indivdual test results in SOAtest are considered as steps for each test case.

```
Example.tst
 ---TestSuite associates with @req 1
   ---Test associated with @pr 2
   ---Test associated with @pr 2
 ---TestSuite associates with @req 3
   ---Test associated with @pr 4
```

will be translated into this in TFS

```
TestPlan
 ---Test Run with id 1
  ---Test Case with id 2
     ---two test steps
 ---Test Run with id 3
  ---Test Case with id 4
```


### MTM
Same structure in MTM
!(/images/mtm.jpg)


## Pasring SOAtest results (report.xml)

### Overview
There are a lot of information in the report but we will be utilizing only several key elements.

The example is using XMLReader for simplicity and efficiency reasons and expect elements in the following order (default order):

1. `ResultsSession` root element and its attributes to get general information for the test run, such as project, session tag, test start time and build number.
2. `TestConfig` element for the configuration and user.
3. `ExecutedTestsDetails` element and its children to gather test result
4. `FuncViols` element for test failures.

##### ResultsSession
ResultsSession is the root element in SOAtest report.xml and the following attributes will be used to populate infomration for a MTM Test Run.
* `buildId` will be used for build number
* `project` will be used for project name
* `tag` will be used for for test environment. Note: tag is a user defiend field "Session Tag" in SOAtest, it can be used to group multiple reports, in this case, a test environment.
* `time` will be used for time start time, we will have to calculate the test end time based of this.

##### TestConfig<commit_msg>fix image syntax<commit_after># SOAtestToMTM

This is an open source example to show how to take a Parasoft SOAtest report.xml and the import test results into Microsoft Test Manager.

This solution includes two projects:

A `SOAtestParser` example to show how to parse SOAtest reports. 
An `MTMImporter` to take the results and send to Team Foundation Server.  

## Prerequisites

This example supports 
* SOAtest 9.8 
* Team Foundation Sever (version )
* Visual Studio 2013, 2015

SOAtest and MTM must be set up correctly with the same assocation structure.

###### Disclaimer
The format of SOAtest reports may be in future updates and how to parse the report will need to be adjusted.

### SOAtest
User must configure the root Test Suite in a tst file with the correct Requirement information that corresponds to the Test Plan sturcture in MTM.

![SOAtest Screenshot](/images/requirement.jpg)

In Requirement and Notes tab of each Test Suite, add the association for each test. Association added for each Test Suite will be inherited by its children.

@req is representing a Test Run
@pr is representing a Test Case

The test results correlated in the following logic:
In each test run (associated with @req) can contain multiple test cases (associated with @pr), each indivdual test results in SOAtest are considered as steps for each test case.

```
Example.tst
 ---TestSuite associates with @req 1
   ---Test associated with @pr 2
   ---Test associated with @pr 2
 ---TestSuite associates with @req 3
   ---Test associated with @pr 4
```

will be translated into this in TFS

```
TestPlan
 ---Test Run with id 1
  ---Test Case with id 2
     ---two test steps
 ---Test Run with id 3
  ---Test Case with id 4
```


### MTM
Same structure in MTM
![MTM Screenshot](/images/mtm.jpg)


## Pasring SOAtest results (report.xml)

### Overview
There are a lot of information in the report but we will be utilizing only several key elements.

The example is using XMLReader for simplicity and efficiency reasons and expect elements in the following order (default order):

1. `ResultsSession` root element and its attributes to get general information for the test run, such as project, session tag, test start time and build number.
2. `TestConfig` element for the configuration and user.
3. `ExecutedTestsDetails` element and its children to gather test result
4. `FuncViols` element for test failures.

##### ResultsSession
ResultsSession is the root element in SOAtest report.xml and the following attributes will be used to populate infomration for a MTM Test Run.
* `buildId` will be used for build number
* `project` will be used for project name
* `tag` will be used for for test environment. Note: tag is a user defiend field "Session Tag" in SOAtest, it can be used to group multiple reports, in this case, a test environment.
* `time` will be used for time start time, we will have to calculate the test end time based of this.

##### TestConfig
{'fraction_non_alphanumeric': 0.06035805626598466, 'fraction_numerical': 0.00784313725490196, 'mean_word_length': 4.0008525149190115, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6680696', 'n_tokens_mistral': 1586, 'n_tokens_neox': 1511, 'n_words': 907}