Hi,
In java it's possible to write unit tests for package-private classes,
when the "test class" is in the same package, like
Foo project:
...
src/main/java/org/apache/blah/PrivateDude.java (in "foo.jar")
src/test/java/org/apache/blah/PrivateDudeTest.java (in "foo-test.jar")
...
But in CSharp/.NET that's not possible when they (-> package-private
class AND TestClass) are different DLLs..., like:
src/main/csharp/org/apache/blah/PrivateDude.cs (in "foo.dll")
src/test/csharp/org/apache/blah/PrivateDudeTest.cs (in "foo-test.dll")
(I think I raised that argument already earlier, here on the list ...)
However it does not mean that it's *impossible* to test internal classes!
A simple work-around is to copy over things to the
'target/build-test-sources' folder, e.g. like:
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-dotnet-sources-to-allow-serious-unit-testing</id>
<phase>generate-test-sources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>target/build-test-sources/</outputDirectory>
<resources>
<resource>
<directory>src/main/csharp</directory>
<filtering>false</filtering>
</resource>
</resources>
<overwrite>true</overwrite>
</configuration>
</execution>
</executions>
</plugin>
I was wondering if others would see some value in modifying the "test
plugin" to include the "source" automatically (in the
build-test-sources folder) to allow serious unit testing of internal
classes etc. :-)
(of course this could be tweaked/triggered by a (configuration) parameter)
Thx!
Matthias
--
Matthias Wessendorf
blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
twitter: http://twitter.com/mwessendorf