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
107 stars 37 forks source link

Inline Resultset Compare Whitespace Value #640

Closed saviourofdp closed 3 years ago

saviourofdp commented 3 years ago

Hi I have a test like the following in which the query should return a single space. How do I test for this with an inline result set? This fails

<?xml version="1.0" encoding="utf-16"?>
<test name="4c7761733738ec849035 Advance Card" xmlns="http://NBi/TestSuite">
    <system-under-test>
        <execution>
            <query>
EVALUATE /* etc */
           </query>
        </execution>
    </system-under-test>
    <assert>
        <equal-to tolerance="0.00001">
            <result-set>
                <row>
                    <cell xml:space="preserve"> </cell>
                </row>
            </result-set>
        </equal-to>
    </assert>
</test>

NBi.NUnit.Runtime.CustomStackTraceAssertionException : Execution of the query doesn't match the expected result

Expected: Result-set with 1 row

0 (Column0)

 KEY (Text)  
 ------------ 
 (null)      

But was:
Result-set with 1 row

0 ([MarketWarning])

 KEY (Text)          
 -------------------- 
 (1 space)           

As you can see I tried the xml:space="preserve" attribute. I also tried replacing the space in the resultset with the term "(1 space)" (thinking it might be undocumented special value like (empty) and (null)).

Also additional question (I can create a new issue if you prefer) : where does tolerence="0.00001" go for an inline resultset?

saviourofdp commented 3 years ago

Sorry I am an idiot (blank) is what I was looking for. Case Closed.

saviourofdp commented 3 years ago

Oops. That didn't work either

NBi.NUnit.Runtime.CustomStackTraceAssertionException : Execution of the query doesn't match the expected result

Expected: Result-set with 1 row

#0 (Column0)
KEY (Text)  
------------ 
(blank)     

But was:
Result-set with 1 row

#0 ([MarketWarning])
KEY (Text)          
-------------------- 
(1 space)           
FuegoArtificial commented 3 years ago

Hi @saviourofdp ,

could you try to use a Space wrapped in a CDATA-Tag? That would enfoce the Space, I believe. That might not be the ideal solution, but what comes to my mind.

for your other question: The tolerance just describes with which difference a test would still pass for decimal values. You have a string, as far as I understand.

Cheers, Tilo

saviourofdp commented 3 years ago

Thanks @FuegoArtificial I will try the CDATA tag.

If I had an inline dataset with multiple data types eg

<equal-to>
    <result-set>
        <row>
            <cell>text 1</cell>
            <cell>0.090234234</cell>
        </row>
        <row>
            <cell>text 2</cell>
            <cell>1.43443443</cell>
        </row>
    </result-set>
</equal-to>

where would the tolerance attribute go?

Thanks

Seddryck commented 3 years ago

NBi is trimming the content of the cell in an embedded result-set. There is no way to work-around this.

Nevertheless, you were right about the usage of (blank), this is the way to handle these cases with whitespaces. The issue here is that your column is considered as a key and not as a value. It sounds that you only have one row returned by the query so I'd switch to a behaviour single row that will let you play only with values.

Regarding tolerance, you must specify a column (with index equal to 1 in your case) and the tolerance you want to apply to this column.

Could you close the issue if it's fixing your problem?