Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage of variables in an assert/equal-to/query #568

Closed
Seddryck opened this issue Dec 1, 2019 · 3 comments
Closed

Usage of variables in an assert/equal-to/query #568

Seddryck opened this issue Dec 1, 2019 · 3 comments
Labels
Milestone

Comments

@Seddryck
Copy link
Owner

Seddryck commented Dec 1, 2019

Reported by @lukzas in #566:

<assert>
  <equal-to>
    <query>
      <parameter name="@table">@Table</parameter>
           SELECT * FROM @table
      </query>
   </equal-to>
</assert>

NBi doesn't sound to understand the variable.

@Seddryck
Copy link
Owner Author

Seddryck commented Dec 2, 2019

This test is perfectly working (available in acceptance tests variable.nbits - line 50 to 68):

  <test name="Usage of the same variable in Sut and Assert" uid="0010">
    <system-under-test>
      <result-set>
        <query>
          <parameter name="common">@common</parameter>
          select @common;
        </query>
      </result-set>
    </system-under-test>
    <assert>
      <equal-to>
        <column index="0" type="dateTime" role="key"/>
        <query>
          <parameter name="common">@common</parameter>
          select @common;
        </query>
      </equal-to>
    </assert>
  </test>

The issue is in the definition of your parameter. It should be the name of the parameter without the arobas (@).

<parameter name="table">@Table</parameter>

@lukzas
Copy link
Contributor

lukzas commented Dec 2, 2019

The reason why I had (@) is that I was executing in <instance-settling> context as per the original issue and this is what I've found in NBi.Testing/Acceptance/Resources/Positive/MultipleInstance.nbits suite line 150 <parameter name="@dept">@department</parameter> 😉

@Seddryck
Copy link
Owner Author

Seddryck commented Dec 3, 2019

The attribute name is expecting the parameter’s name without the @. At the best, not checked, if you add a @ then the parameter’s name would become dynamic and based on variable value (should be tested).

About the test you mentioned, I’ll have to double-check but I’m relatively sure that the parameter is ignored by the query (unexpected) and the query is returning more than 10 rows anyway. Thx the heads up I’ll check this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants