Seddryck / NBi

NBi is a testing framework (add-on to NUnit) for Business Intelligence and Data Access. The main goal of this framework is to let users create tests with a declarative approach based on an Xml syntax. By the means of NBi, you don't need to develop C# or Java code to specify your tests! Either, you don't need Visual Studio or Eclipse to compile your test suite. Just create an Xml file and let the framework interpret it and play your tests. The framework is designed as an add-on of NUnit but with the possibility to port it easily to other testing frameworks.
http://www.nbi.io
Apache License 2.0
106 stars 37 forks source link

New alteration "union" to create a single result-set from two #620

Closed Seddryck closed 3 years ago

Seddryck commented 3 years ago

It should be possible to combine two result-sets if they have the same columns.

<result-set>
  <query> ... </query>
  <alteration>
    <union>
      <result-set>
        <query>...</query>  
      <result-set>
    </union>
  </alteration>
</result-set>
Seddryck commented 3 years ago

Implemented and documented in 1.23.0-beta.72 or on nuget via Update-Package NBi.Framework -version 1.23.0-beta0072.

lukzas commented 3 years ago

@Seddryck It seems to work only with result-set element inside union as schema validation error is thrown during runtime:

NBi.NUnit.Runtime.TestSuite.ExecuteTestCases:
System.ArgumentException : The test suite is not valid. Check with the XSD. 1 error has been found during the validation of the test-suite:
    At line 514: The element 'union' in namespace 'http://NBi/TestSuite' has invalid child element 'query' in namespace 'http://NBi/TestSuite'. List of possible elements expected: 'result-set' in namespace 'http://NBi/TestSuite'.

Also, I've looked into the schema, and indeed result-set is the only element specified for the union:

<xs:complexType name="union-type">
    <xs:sequence>
      <xs:element name="result-set" type="result-set-type" minOccurs="1" maxOccurs="1"/>
    </xs:sequence>
    <xs:attribute name="column-identity" type="column-identity-enum" use="optional"/>
  </xs:complexType>

I'm not sure if it's a beta limitation or a bug 😜

Seddryck commented 3 years ago

This a feature. If it was directly a query and not a result-set, it wouldn't have been possible to add an alteration to this second result-set. I'll update the feature-request.

Seddryck commented 3 years ago

But something to improve is probably that we should be able to have more than a single union.

lukzas commented 3 years ago

Ok. Then I guess docs (https://www.nbi.io/docs/resultset-alteration/) also need an update as there is an example where you can use query inside.

<result-set>
  <query>
    select 'Apple' as Fruit, 10 as Qty union all select 'Orange', 15
  </query>
  <alteration>
    <union column-identity="name">
      <query>
        select 5 as Qty, 'Apple' as Fruit, 'Fall' as Season
      </query>
    </union>
  </alteration>
</result-set>