Out of curiosity I tried the following:

<nunit2>
  <formatter type="Xml" />
  <test>
    <assemblies basedir="${basedir}">
      <include name="**\bin\${config}\*.dll" />
    </assemblies>
  </test>
  <test testname="TestNamespace"
assemblyname="c:\path\to\first\test.dll" />
</nunit2>

I found that NAnt faithfully executed both <test> sections.
Unfortunately, the tests require that the working directory be the
directory where the assembly exists. Some of the tests in the second
<test> section fail because they working directory is still the working
directory of the last assembly executed in the first <test> section.
Currently the first <test> section only matches one assembly so I'm not
sure if this behavior extends to it as well.

So the first question is, assuming that the fileset in the first <test>
section matches multiple assemblies in different directories, does nant
setup the working directory to the directory where the matched assembly
lives? I expect that it will but don't have a setup at the moment to
test it.

The second question is does the code above semantically legal? In other
words is it illegal for <nunit2> to have more than one <test> element?

The reason I tried the above is because I really want to generate a
single fileset that also has knowledge of the corresponding testname for
each assembly matched. So if I write something similar to the following:

<nunit2>
  <formatter type="Xml" />
  <test>
    <assemblies basedir="${basedir}">
      <include name="**\bin\${config}\*.dll" />
      <include name="c:\path\to\first\test.dll" testname="TestNamespace"
/>
      <include name="**\old\${config}\*.dll" testname="OldTests" />
      <exclude name="**\Interop.*.dll" />
    </assemblies>
  </test>
</nunit2>

NAnt would execute all the tests (default behavior) in each assembly
matched by the first <include> and only execute the tests in
TestNamespace for the second <include>. In the third <include> only the
tests in OldTests for each assembly matched are executed. Everything
else can work as normal.

Of course, this would be even more useful if I could declare the
<assemblies> fileset outside the <test> element and reference it later
like this:

<project name="test" default="test">
  <assemblies id="testset" basedir="${basedir}">
    <include name="**\bin\${config}\*.dll" />
    <include name="c:\path\to\first\test.dll" testname="TestNamespace"
/>
    <include name="**\old\${config}\*.dll" testname="OldTests" />
    <exclude name="**\Interop.*.dll" />
  </assemblies>
  <target>
    <nunit2>
      <formatter type="Xml" />
      <test>
        <assemblies refid="testset" />
      </test>
    </nunit2>
  </target>
</project>

Then my current framework could stay in place. Right now I have a common
script that is used by a number of testsuites. The common script is
complete enough that each testsuite only "overrides" certain aspects
like which tests to execute. Right now each individual testsuite needs
to define a "special" target named test.assemblies which will define the
test.assemblies fileset. The common script determines at runtime if the
test.assemblies target exists and executes it if it does, otherwise it
executes a test.default-assemblies target. Then it executes the tests in
the fileset. This worked so far because I wanted to execute all tests in
the test assemblies. I'm now trying to add a test assembly that has its
tests divided between two namespaces. I can only run the tests in one of
those namespaces because the other ones require hardware to be present
and must be supervised in case of hardware malfunction. Given this
scenario I need the ability to specify the testname information at the
assemblies fileset level. How likely is it to get this supported?

-- Edwin


-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Nant-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to