unit-testing

WCF Security error with VS 2008 Unit Test

I am in my rookie season with WCF Services... I was running my first Visual Studio 2008 Unit Test with a WCF Service and I received the following error: Test method UnitTest.ServiceUnitTest.TestMyService threw exception: System.ServiceModel.Security.MessageSecurityException: The HTTP request is unauthorized with client au...

The located assembly's manifest definition does not match the assembly reference

I am trying to run some unit tests in a C# winforms application (VS 2005) and I get the following error: System.IO.FileLoadException: Could not load file or assembly 'Utility, Version=1.2.0.200, Culture=neutral, PublicKeyToken=764d581291d764f7' or one of its dependencies. The located assembly's manifest definition does not match the ass...

How can I unit test a GUI?

The calculations in my code are well-tested, but because there is so much GUI code, my overall code coverage is lower than I'd like. Are there any guidelines on unit-testing GUI code? Does it even make sense? For example, there are graphs in my app. I haven't been able to figure out how to automate the testing of the graphs. It takes a ...

Searching for file dependency for nunit unit testing

I had a winforms C# class that internally was looking up a file.. to help unit test, i changed it to pass in a file from the outside such as: string file = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location + "TestXML.xml"); Foo = new Foo(file); the problem is that the code works fine normally but when run in Nunit it come...

how to generate unit test code for methods

i want to write code for unit test to test my application code. I have different methods and now want to test these methods one by one in python script. but i do not how to i write. can any one give me example of small code for unit testing in python. i am thankful ...

Automated testing (non-UI) for existing Flash component

I build and maintain a set of Flash components that is distributed to publishers and allows them to integrate with our system. Currently the component has no UI and simply contains compiled code for querying our system servers, parsing the response, and modifying the params sent in the query. There's an As2 version and AS3 versions for b...

How to write a MSTest unit test that listens for an event to be raised from another thread?

I’m writing a test that expects to receive an event from an object that it is calling. Specifically, I am calling out to an object that connects to an AIX machine via SSH (using the open source Granados project), then disconnecting, and I want to make sure I receive the OnConnectionClosed event that is being raised during the disconnect....

How do you configure WCF to support FaultContracts where both the host and client are in the same process using a net.pipe?

I'm trying to create an in-process unit test for my service to client interactions using net.pipe binding. Like a good WCF service it uses FaultContractAttribute on service operations to expose possible faults (wrapped exceptions) to metadata. I would like to have the client and service endpoints configured thru XML (App.config). Howe...

Unit testing with C/C++: Lessons, what to remember?

Unit testing with C/C++: What do you teach people who either did not do unit testing before or come from Java/Junit? What is the single most important lesson / thing to remember/ practice from your point of view that saves a lot of time or stress (especially regarding C/C++)? ...

Unit Tests Visual Studio

Can anbyody tell me how to include a certain folder when running unit tests in visual studio. In the folder are xml-files needed by the tests. I can't seem to find anymore where I need to add this folder. Thx, Lieven Cardoen aka Johlero ...

Adding unit tests to an existing project

My question is quite relevant to something asked before but I need some practical advice. I have "Working effectively with legacy code" in my hands and I 'm using advice from the book as I read it in the project I 'm working on. The project is a C++ application that consists of a few libraries but the major portion of the code is compil...

How do I avoid duplicated code in my tests and avoid mocking on self?

In my question As a “mockist” TDD practitioner, should I mock other methods in the same class as the method under test?, Avdi answered "Personally I think that mocking on self is almost always a code smell. It's testing the implementation rather than the behavior." He may be right, but often I can't distinguish between the implementatio...

Business logic invading UI in a large winforms app

I have seen this theme present itself more than once now. I am hoping that people here who are currently in similar situations or have been in the past can offer some insightful advice. It might be useful if you share your past experiences as well. So there is this fairly large windows forms application that has been developed over the ...

How can I Fail a WebTest?

I'm using Microsoft WebTest and want to be able to do something similar to NUnit's Assert.Fail(). The best i have come up with is to throw new webTestException() but this shows in the test results as an Error rather than a Failure. Other than reflecting on the WebTest to set a private member variable to indicate the failure, is there s...

Mocking non-public static methods in abstract classes with JMockit?

I have the following class: public abstract class AbstractParent { static String method() { return "OriginalOutput"; } } I want to mock this method. I decide to use JMockit. So I create a mock class: public class MockParent { static String method() { return "MOCK"; } } And my test code looks like thi...

Implementing xunit in a new programming language

Some of us still "live" in a programming environment where unit testing has not yet been embraced. To get started, the obvious first step would be to try to implement a decent framework for unit testing, and I guess xUnit is the "standard". So what is a good starting point for implementing xUnit in a new programming language? BTW, sinc...

Can I create a unit test for a method which marshalls a value from an IntPtr?

I am using a native library which returns an IntPtr to a memory location, which contains the value of an attribute. I know what the type of the attribute is and I have a method for marshalling a value (taking the IntPtr and the type of the attribute) from the memory pointed at by the pointer. This method either calls Marshal.ReadInt32,...

Automated unit testing SSIS packages

How can I unit test SSIS packages? I want to be able to create and maintain unit tests for various components such as the workflow tasks, data flow tasks, event handlers, etc. Are there any existing techniques, frameworks, and/or tools that can be used? ...

How do you use debugging to step into a class in a web application from a test project in the same solution?

When using NUnit and the test project, we haven't been able to find a way to step into the class we are testing in a web application. We are using TestDriven.NET add-in for Visual Studio 2008. We are able to hit a breakpoint in the test project, but not step into the web app class that is being tested. ...

How can I get "Copy to Output Directory" to work with Unit Tests?

When I build a unit test project before the tests are executed the test output is copied to a TestResults folder and then the tests are executed. The issue I'm having is that not all the files in the Debug/bin directory are copied to the TestResults project. How can I get a file that is copied to the Debug/bin directory to also be copi...