unit-testing

How to Generate a WSDL in c# without making a http request

Greetings, I want to write a unit test to make sure that our web services have not changed the WSDL from the last known published version. The reason for this is because any change to a object in the WSDL will cause clients using Apache Axis to fail. Even if all you do is add a not-requred property. So, if there is a change then the ...

What is Unit Testing for Web Development?

I have heard the term unit testing many times and I am wondering how this is related to the web development field. I program with PHP, Javascript, Actionscript 3.0 and I am starting to get into C++, C# and JAVA. If anyone has any good resources that I can take a look into as I believe this is a good method to follow for "test driven" dev...

How to unit test the default case of an enum based switch statement

I have a switch statement in a factory that returns a command based on the value of the enum passed in. Something like: public ICommand Create(EnumType enumType) { switch (enumType) { case(enumType.Val1): return new SomeCommand(); case(enumType.Val2): return new SomeCommand(); case(enumType.Val3...

Rhino mocks - does this test look sensible?

I have just crafted the following test using Rhino mocks. Does my test look valid and make sense to those more experienced with mocking? I am a a little confused that I haven't had to use the DynamicMock() or StrictMock() methods to create a seemingly valid test. This test tests that the Add method was invoked on the supplied ICachingS...

Generate custom test result in Visual Studio 2008

Hi, I'm elaborating some unit tests and I'm not sure if what I want is possible with Visual Studio 2008. Basically, I'm scanning some classes and for each of them, I want to know if this class is serializable and if it has a default constructor. I would like to have in the Test Results View the list of ALL the classes that I had teste...

Mocking an NHibernate ISession with Moq

Hello, I am starting a new project with NHibernate, ASP.NET MVC 2.0 and StructureMap and using NUnit and Moq for testing. For each of my controllers I have a single public constructor into which an ISession is being injected. The application itself works just fine, but in terms of unit testing I essentially have to mock an ISession in or...

An overview of unit testing terminology ( stub vs mock , integration vs. interaction )?

I'm using more unit tests in my projects and reading all the information I can online and am getting confused by a lot of the terminology. As a result I'm probably these terms incorrectly in conversation and google searches. Can somebody outline all the unit testing terms like the "fake" types as well as types of test ( interaction vs. ...

Create Unit test methods dynamically during runtime in MSTest

Is there an equivalent of SuiteBuilder in MSTest? couldn't find one so far. I have a bunch of xml files, each to be seen as mapped to a test method. As there are 100s of these and to manually write tests for each of these, is not a good idea. So in nunit you could implement ISuiteBuilder and have the Test cases run dynamically and show...

Is there a better way to implment Equals for object with lots of fields?

see also Hows to quick check if data transfer two objects have equal properties in C#? I have lot of Data Transfer Objects (DTO) that each contains lots of simple fields. I need to implement Equals on all of them (so I can write some unit tests off transporting them var WCF). The code I am using is: public override bool Equal...

asserting against a functions output on its own unit-test?

Hello, If that title did not make sense (which I'm expecting =)) here is what I'm asking: I have a function called ParseFile(). It takes a string as parameter, and a DataTable as a return value. I want to unit-test this function. Is it wrong of me to code the function first, run it, take the output, serialize it to XML, save it as exp...

How does one create a global testfixturesetup routine with MBUnit and C#?

I'm using MBUnit for my test project and have a setup routine that must run before several different test fixtures can run properly. Currently in each TestFixture I've got the [TestFixtureSetup] attribute on a routine that performs this, but the logic is unnecessarily duplicated in each individual test fixture. What method is used to c...

Bad form for JUnit test to throw exception?

Hi. I'm pretty new to JUnit, and I don't really know what best practices are for exceptions and exception handling. For example, let's say I'm writing tests for an IPAddress class. It has a constructor IPAddress(String addr) that will throw an InvalidIPAddressException if addr is null. As far as I can tell from googling around, the test...

Debug Windows Mobile unit-tests in VS2008

Hello, I started Windows Mobile 6.x development but I am facing a problem when I want to unit-test my classes. In fact when I run the tests everything goes like it should: VS launches the emulator and then runs the tests. But when I try to debug them, it launches emulator, runs the tests but my breakpoint are never hit. It seems that d...

Unit testing a Microsoft Project AddIn

I have a Microsoft Project Client AddIn. In it I have a POCO Calculation class that contains a method called CalculatePrice() of which function is to iterate through the current active project and calculate a price figure for each of the task assignments. Now, this CalculatePrice() method is not only complex, but is also a critical func...

How to invoke $(document).ready(function() {}) in unit testing

Hi all: I'm experiencing difficulties trying to invoke document.ready( function() {}) in my unit tests. Suppose I have multiple of them in my javascript file, and one of them called inside a named function i.e. function myFunction() { $(document).ready(function() { //... }); } How do I actually invoke them in my uni...

Unit Testing: Using another method to check the method under test ran correctly

I am working on writing unit tests properly, and I wonder is it bad technique to test the result of a method under test by calling another method to verify the result? ie. in the below example I can only check that an StoreObject method call was successful(ie. a object being stored in the cache) by calling either FetchObject or the HasC...

How to structure unit tests that have dependencies?

Given the following simple example: class MathObject(object): """ A completely superfluous class. """ def add(self, a, b): return a + b def multiply(self, a, b): result = 0 for _ in range(b): result = self.add(result, a) return result Obviously, multiply() calls add() internall...

Rails Functional Tests - I can't assert a template from another controller's view in my functional test.

If controller A's action redirects to another controller B's action, can i check in A's functional test that B's action template is being rendered? in controller As fucntional test i.e. assert_template 'controllerB/some_view' I know that this should be done in controllers Bs tests but I'm wondering if it is technically possible? I ha...

Invoke callback in Moq

I have a method that performs an asynchronous service call. I call this class by passing in the callback. public void GetRights(EventHandler<GetRightsCompletedEventArgs> callback) { ServiceClient client = new ServiceClient(); client.GetRightsCompleted += new EventHandler<GetRightsCompletedEventArgs>(callback); client.GetRig...

Python, unit test - Pass command line arguments to setUp of unittest.TestCase

I have a script that acts as a wrapper for some unit tests written using the Python unittest module. In addition to cleaning up some files, creating an output stream and generating some code, it loads test cases into a suite using unittest.TestLoader().loadTestsFromTestCase() I am already using optparse to pull out several command-li...