[en] Unit Test throw weird exception (solved)

Topics: Technical Support
Coordinator
Mar 27, 2011 at 11:41 AM

When I run the unit tests defined in OneWayTests.cs the test environment throws the following exception:

Der Typ für Member "Zyan.Communication.LogicalCallContextData,Zyan.Communication, Version=1.9.0.0, Culture=neutral, PublicKeyToken=null" wurde nicht aufgelöst.

Translated to English this means:

The type for member "Zyan.Communication.LogicalCallContextData,Zyan.Communication, Version=1.9.0.0, Culture=neutral, PublicKeyToken=null" was not resolved.

When I first start to write tests for Zyan (Distributed Events test), I got the same error and no solution to fix it. This is why I switched from unit tests to generic tests. I think the test environment has problems, becuase Zyan modifies the remoting call context. Zyan puts its own type to the call context. This type is unknown from the sight of the Test Environment and cannot be resolved.

Do you get that error too?

Coordinator
Mar 27, 2011 at 3:17 PM

Yes, I get this error too if I run tests from VS2010 IDE by clicking «Run tests» button.

I think it's a problem of Visual Studio MSTest integration. MSTest framework itself is able to run these unit tests. I am using TestDriven.NET Visual Studio addin, and it doesn't show any errors (that's why I didn't notice any problems with unit tests before your report).

>When I first start to write tests for Zyan (Distributed Events test), I got the same error and no solution to fix it.

I can only suggest to install free personal edition of TestDriven.NET addin (it's very lightweight and quite handy indeed).

And by the way. Please consider switching to open-source unit testing framework (such as NUnit, for example).

MSTest is good, but it's quite slow and (which is worse) is not available in Express versions of Visual Studio. It also generates lots of large and verbose report files, which should be deleted manually :)

Coordinator
Mar 27, 2011 at 7:18 PM
Edited Mar 27, 2011 at 7:21 PM

I´ve no experience with NUnit. But if the effort for writing tests with NUnit is not higher than using MSTest, we can switch to NUnit. MSTest is integrated in Visual Studio. I took it only because it was already integrated and easy to handle.

I installed the TestDriven.NET addin and now all tests are working. But what about the reporting? The TestDriven.NET addin only says failed or passed. Is there a way to get more details about a test run?

Coordinator
Mar 27, 2011 at 9:01 PM
Edited Mar 27, 2011 at 9:02 PM

>I´ve no experience with NUnit. But if the effort for writing tests with NUnit is not higher than using MSTest, we can switch to NUnit.

I've used both, and they seem to be pretty much the same. MSTest uses [TestMethod] attribute while NUnit uses [Test]. I don't know of any real differences, except that MSTest is not free (not included in VSExpress) and is not available on non-Windows platforms.

>The TestDriven.NET addin only says failed or passed. Is there a way to get more details about a test run?

As fas as I know, TestDriven.NET only reports test failures (in the ErrorList window, so you can double-click error to get to the line where your assertion failed or exception was thrown). Short summary (X tests passed, Y failed, Z skipped, took T seconds) as well as Trace.WriteLine(...) calls are shown in the Output window. That's basically all. It doesn't provide cool treeviews with red/green dots and don't generate XML reports (at least, free edition that I use).

The only real drawback of TestDriven.NET (compared to VS-integrated MSTest) is that edit-and-continue feature is not available. In MSTest, I can edit tests as well as classes being tested and apply modifications on-the-fly during the same test run. This is quite handy and it seems to be the only real advantage of MSTest I am aware of.

Coordinator
Jul 2, 2011 at 1:37 PM

I've created a separate project for NUnit tests.

All unit tests can now run under both MSTest 10.0 (Windows) and NUnit 2.5.10 (Windows and Linux). All test classes are reused between two projects.

The original idea of unit test abstraction layer is by Roman Ivantsov, the author of Irony parsing toolkit and VITA ORM.

Coordinator
Jul 18, 2011 at 7:33 PM

That´s great! So everybody can use his preferred test framework.