1

I want to create a new test with a regression test as the parent using the VersionOne .Net SDK. This code throws Violation'Required'AttributeDefinition'Parent'Test: NULL on the line _services.Save(newAsset)

This is the code I am using:

var parentAssetType = "RegressionTest";
var typeOfAsset = "Test"; 
var assetTitle = "My New Test";

public Asset AddNewAsset(string parentAssetType, string typeOfAsset, string assetTitle)
    {
        var projectId = Oid.FromToken(parentAssetType + ":0", _metaModel);
        Console.WriteLine(projectId.Token);
        var assetType = _metaModel.GetAssetType(typeOfAsset);
        var newAsset = _services.New(assetType, projectId);
        var nameAttribute = assetType.GetAttributeDefinition("Name");
        newAsset.SetAttributeValue(nameAttribute, assetTitle);
        _services.Save(newAsset);

        var newAssetId = newAsset.Oid.Token;
        var parentAssetId = newAsset.GetAttribute(assetType.GetAttributeDefinition(parentAssetType)).Value;
        var newAssetName = newAsset.GetAttribute(nameAttribute).Value;
        _logger.Log(Loglevel.Debug, "New Asset Id:{0} --- Parent Asset Id:{1} --- New Asset Name:{2}", newAssetId, parentAssetId, newAssetName);
        Console.WriteLine("New Asset Id:{0} --- Parent Asset Id:{1} --- New Asset Name:{2}", newAssetId, parentAssetId, newAssetName);

        return newAsset;
    }

I am closely following the exampele found here: https://github.com/versionone/VersionOne.SDK.NET.APIClient#learn-by-example-new-asset

In the paragraph before the example, the author explains "When you create a new asset in the APIClient you need to specify the "context" of another asset that will be the parent. For example, if you create a new Story asset you can specify which Scope it should be created in".

In the example the parentAssetType is set to "Scope:0". However, I think it is supposed to be a specific id of an already existing asset. I tried this code with a real existing scope number and the same error was thrown which leads me to believe I am missing the real problem.

Jonathan Kittell
  • 7,163
  • 15
  • 50
  • 93

2 Answers2

2

From the details page of the Tests (created under the Story or Defect), under the "Edit" drop down is an option to "Generate Regression Test" for that workitem.

Also , under the "Product Planning" tab is a link to the "Regression Tests" page. Here you can create new Regression Tests that are associated to the project or sub-projects you are working in, as well as displaying the Regression Test generated from the workitem.

Once the you have created the Regression tests, you can go to the "Release Planning" tab > and then to the "Regression Planning" page. Here you create the Regression Plan > New Test Suite > and then Assign the regression tests to the suite created.

*Note: The tests that are created directly for a Story or Defect, will not show up for selection to assign to the Test Suite, only the regression tests created via from the regression tests page or from the test details page of the workitem.

Once the tests have been added to the suite, Test Sets can be generated to contain the executable acceptance tests as well as the regression tests assigned to the suite.

** NOTE ** **Regression Tests or Tests can not be a Parent test or a Child Test.

I hope this helps.

1

You will have to create your test with a PrimaryWorkitem (Story, Defect) as the parent. RegressionTests do not contain "Tests". There is one exception, since a RegressionTest can hold a reference to a test in an attribute called "GeneratedFrom". This can refer to the Test that the RegressionTest was generated from.

Mark Irvin
  • 830
  • 1
  • 6
  • 16