You could use entities to do this, or preprocess the file using something like XIncluder. SQLUnit does not have a native mechanism to do this.
Example of entities:
declare it in the beginning of your test file:
<!ENTITY myentity SYSTEM "included.sql">
and then reference it:
<test>
<call><stmt> &myentity;</stmt></call>
<result />
</test>
With XIncluder (xincluder.sf.net), you set up xi:include tags in your source file and run it through XIncluder. This is not as cumbersome as it sounds if you have everything automated, so your source file lives in your repository, you generate temporary SQLUnit test files for testing.
-sujit
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
My test sql is quite a long query. Is it possible to include it from a file rather than copy and pasting it multiple times in my unit test?
Many thanks,
Chris
Hi Chris,
You could use entities to do this, or preprocess the file using something like XIncluder. SQLUnit does not have a native mechanism to do this.
Example of entities:
declare it in the beginning of your test file:
<!ENTITY myentity SYSTEM "included.sql">
and then reference it:
<test>
<call><stmt> &myentity;</stmt></call>
<result />
</test>
With XIncluder (xincluder.sf.net), you set up xi:include tags in your source file and run it through XIncluder. This is not as cumbersome as it sounds if you have everything automated, so your source file lives in your repository, you generate temporary SQLUnit test files for testing.
-sujit
I will give it a try.
Many thanks,
Chris