Re: [nunit-discuss] Occasional "The server did not provide a meaningful reply;.." exception

352 views
Skip to first unread message

Charlie Poole

unread,
May 7, 2013, 2:17:17 PM5/7/13
to NUnit-Discuss

To assist you in this it will be helpful to know the environ,sent. How are you running your tests?

On May 7, 2013 10:51 AM, "Didi" <e.ma...@gmail.com> wrote:
I have a set of 30 NUnit functional tests, occasionally, some of my NUNit tests will fail because they did not receive the expected exception message. The server logs the correct exception message that was thrown in these cases, but for some reason NUnit gets a garbled or truncated version of this message  - some times :( - and that is the painful part - sometimes all my tests pass - meaning the correct exception messages are received and sometimes a couple or more will fail. I would like to increase the MaxMessageSize for received WCF messages on NUnit - how do I go about this? Does any one else have any other suggestions on how to debug this problem? My Tests are decorated with attributes similar to this: [ExpectedException(ExpectedMessage = "The stored procedure '[dbo].[InvalidSP]' doesn't exist.")].

--
You received this message because you are subscribed to the Google Groups "NUnit-Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nunit-discus...@googlegroups.com.
To post to this group, send email to nunit-...@googlegroups.com.
Visit this group at http://groups.google.com/group/nunit-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Didi

unread,
May 7, 2013, 2:28:09 PM5/7/13
to nunit-...@googlegroups.com
My server is running as a service. It exposes an interface that i call into. My tests are written within Visual studio 2010. I connect to the server and call methods on this interface (IDatabaseService). I am testing creation, duplication, deletion and updating of database connection objects as well as retrieval of data from the database. I have negative tests that will sometime pass in null or invalid connection object parameters, null or invalid stored procedure names etc. Only the negative test sometimes fail...the positive tests (when my parameters are not null or invalid) always pass. I am using nunit 2.4.8...

Charlie Poole

unread,
May 7, 2013, 2:44:07 PM5/7/13
to NUnit-Discuss
How do you run nunit? For example, are you using the Gui? (People often forget that there are many ways to run NUnit tests... at least half a dozen I can think of.)

As you probably know, the NUnit version you are using is about five years old. We may be able to give you some advice here about things you can do but any changes to NUnit would be reflected in the next release - 2.6.3 or maybe 3.0.

NUnit is not in itself aware of WCF. It uses .NET remoting to connect to _tests_ run in another domain or process. In your case, I assume that the tests themselves are making a server connection using WCF. You should bear in mind that any tests run through such a connection can return exceptions that are unrelated to the operation you are performing - for example, the server may be down. Additionally, if you return any custom exceptions, passing them back to NUnit - especially an older version - may cause a failure that hides the original error. Essentially, NUnit needs to have type information for anything that comes back to it via an exception.

Charlie

Didi

unread,
May 7, 2013, 5:33:10 PM5/7/13
to nunit-...@googlegroups.com
I created an nunit project file, and kick this off using nunit-console.exe. So i have a separate console application that runs nunit-console with the right parameters multiple times ( I wait for each process to be finished before starting up the next process) - that's the only way that i can be sure to catch the error.

Unfortunately, I cannot change the version of nunit  - it's what we use at work. When an exception is thrown by WCF, does it matter that the rethrow is simply "throw;" or must it use 'throw e;" for example, where e is the exception instance?

Charlie Poole

unread,
May 7, 2013, 5:41:57 PM5/7/13
to NUnit-Discuss
I see. If the opportunity arises, tell the folks at work who make such decisions that NUnit 2.4.8 was the last bug fix release in the 2.4 series. IOW, aside from new features, you are missing all the errors that were fixed over the past five years! And if this conversation uncovers an NUnit bug, it will be fixed in an NUnit release that you don't use!

There are some tricks to rethrowing an exception without loss of information, which NUnit does not currently use. I'm looking at this for 3.0. Bear in mind, however, that there is no "trick" that will teach NUnit to understand an exception of a custom type - if you have any.

Charlie

Didi

unread,
May 8, 2013, 1:13:43 PM5/8/13
to nunit-...@googlegroups.com
Hello Charlie,

So, i made some progress with this:

I turned on WCF tracing on the server and nunit application and filtered out the wcf calls back and forth.

Looking at a particular test: UpdateConnection_WithInvalidDSN, ran 50 times - it fails only once.

Note: The test fails when nunit does not receive the expected exception message.

For the 49 times when it passes, here is the server WCF trace:

Exception Type: System.Data.Odbc.OdbcException, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

Message: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

nunit-console WCF trace:

Exception Type: System.ServiceModel.FaultException`1[[System.ServiceModel.ExceptionDetail, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

Message: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

When the test fails we get:

Server WCF trace

Exception Type: System.Data.Odbc.OdbcException, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

Message: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

nunit-console Trace

Exception Type: System.ServiceModel.CommunicationException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

Message: The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.

Any ideas why this would happen? I am going to try removing all the ExceptionExpectedAttributes that decorate the test cases, and instead use try-catch with Asserts within each test case, just to see if i get a different behaviour.

Thanks,

Didi
Reply all
Reply to author
Forward
0 new messages