This project is read-only.

Test side effects of an Etl

Version 1.6 introduces tests for Etl, for more info about this read here []
The first role of an Etl is often to introduce changes to the state of other objects (database content, create, move or delete files, …). NBi is supporting a way to test these state's changes after the run of the given etl. The process to achieve this is firstly to run the etl during the setup phase, then define your system-under-test as the objected impacted by your etl (by example, through a query to a table) and finally assert the correct state of this object (the content of the result-set returned by your query).

Define your test

In the sample bellow the etl will read the content of a file and populate a table. To test that the file has been correctly loaded we’ll execute a select on the corresponding table and compare with the content of this file.
In the xml element named “setup” you’ll need to define your etl to run. The syntax is exactly the same than for etl defined in a system-under-test (see Etl).
<test name="Etl in setup" uid="0003">
  <setup>
    <etl-run name="Sample.dtsx" path="Etl\">
      <parameter name="DataToLoadPath">C:\data.csv</parameter>
    </etl-run>
  </setup></test>

Next, you’ll need to define your query on a table as a system-under-test
<system-under-test>
  <execution>          
    <query>
      select CurrencyCode, Name from [Sales].[Currency]
    </query>
  </execution>
</system-under-test>

And finally to define your expected result-set:
<assert>
  <equalTo keys="first">
    <column index="1" type="text" role="value"/>
    <resultSet file="C:\result.csv"/>
  </equalTo>
</assert>

The whole sample would be:
<test name="Etl in setup" uid="0003">
  <setup>
    <etl-run name="Sample.dtsx" path="Etl\">
      <parameter name="DataToLoadPath">C:\data.csv</parameter>
    </etl-run>
  </setup>
  <system-under-test>
    <execution>    
      <query>
        select CurrencyCode, Name from [Sales].[Currency]
      </query>
    </execution>
  </system-under-test>
  <assert>
    <equalTo keys="first">
      <column index="1" type="text" role="value"/>
      <resultSet file="C:\data.csv"/>
    </equalTo>
  </assert>
</test>

Last edited Oct 6, 2014 at 10:30 PM by Seddryck, version 2

Comments

No comments yet.