unit-testing

Remove dependancies on wcf services so I can unit test the class

I want to remove dependencies from my classes for WCF Services. I want to inject them into the constructor as an interface and then mock the interface when I am testing that class. What is the best practice and the fastest way for doing this? my class: class Test { public IMyWCFInterface _wcf; public Test(IMyWCFInterface wcf) { _wcf...

Trying to gain confidence in the benefits of TDD

I just bought The Art of Unit Testing from Amazon. I'm pretty serious about understanding TDD, so rest assured that this is a genuine question. But I feel like I'm constantly on the verge of finding justification to give up on it. I'm going to play devil's advocate here and try to shoot down the purported benefits of TDD in hopes that ...

Unit tests in a seperate project

Hello Everyone, Long time viewer, first time questioner here. Using Unit Tests in a separate project, I can't figure out how to separate them at the release build? Surely when I remove the reference to the Unit Test project, all the references to the Unit Test interfaces, won't be able to find the interfaces and will cause compiler err...

Unit test behaviour after exception is thrown?

Hi all, I am just starting out with unit testing and have a scenario I'm not sure how to appraoch and my solution doesn't feel right. I have a bit of code that does something, if it fails i.e. throws an exception the exception is caught and logged as below. public T CreateTypedObjectInstance<T>() { T o = default(T); try ...

Ruby unit test :run a test class from the main class

In Ruby unit testing can I run a test class from another class for exa class Foo < Test::Unit:: TestCase test_abc() test_bnd() Now i want to run this above test suite from my main class so how could i do it I tried using runner but dono wat should be argument to the run method Test::Unit::UI::Console::TestRunner.run(FOO) , R...

Testing Android ContentProvider that accesses the Internet

I've written my own Android ContentProvider for accessing certain Internet resources. I'm trying to write some unit tests, but I do not want those tests to actually access the Internet. Behind the scenes, my code is using the DefaultHttpClient class to access the web. Basically, I'd like to know how I can use the ProviderTestCase2 cla...

Testing if another method on same object was called with testing the targetObject

public Class Test{ GetDataset(RandomBoolean uncertain); GetDataset2(); GetDataset3(); } where method definitions are public virtual void GetDataset2(){} public virtual void GetDataset3(){} public virtual void GetDataset(RandomBoolean uncertain) { if (uncertain.State){ GetDataset2(); } ...

Weird problem with JSMock

Can someone explain what's going on here, and how to fix it? I'm using JSMock, and executing the following code in spec.js: for (var t in []) { alert(t) } ... causes my browser to alert "eachIndexForJsMock" (when it shouldn't execute the alert command at all). This is messing up my for each loops. How do I fix it? ...

Why does calling Session.Clear() cause this test to fail?

The following is a simple test of a repository against FluentNHibernate-1.1.0.685 (NHibernate-2.1.2.4000). The Session and NH config are provided by the test fixture. [Test] public void ShouldEdit() { var employee = CreateEmployee(); session.Clear(); var changedEmployee = _testRepository(employee.id); changedEmployee....

How to pass Xml data as a parameter to a Test in mbunit v3

I was reading about data driven testing using mbunit from this article. http://blog.benhall.me.uk/2007/04/mbunit-datafixture-data-driven-unit.html I am using v3 of mbunit now and the attributes used for DataDriven testing are Not applicable in V3 as per the release notes for V3. Using this article http://blog.bits-in-motion.com/2009/03/...

Documentation for mbunit v3

Any pointers for the documentation on the new features of mbunit v3? ...

Mocking a type with an internal constructor using Moq

I'm trying to mock a class from the Microsoft Sync Framework. It only has an internal constructor. When I try the following: var fullEnumerationContextMock = new Mock<FullEnumerationContext>(); I get this error: System.NotSupportedException: Parent does not have a default constructor. The default constructor must be explicit...

Can I use the current release of Unitils (3.1) with JPA 2.0?

Using Hibernate EntityManager 3.5.3-Final together with Unitils 3.1 results in: unitilsAfterTestTearDown(com.unifiedpost.payments.model.TestAccount) Time elapsed: 0.02 sec <<< FAILURE! java.lang.AbstractMethodError: org.springframework.orm.jpa.persistenceunit.SpringPersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMo...

How to copy a Visual Studio database unit test

I'm writing unit tests for stored procedures in VSTE for Database Professionals, and want to copy some already existing test cases that only need to be modified in a few places. Manually re-creating them would be very tedious. I couldn't find a solution either on the web or in books. Any ideas are welcome. ...

Unit-test passes in Debug, but hangs when Run

I have an odd problem. I have a unit test that keeps getting stuck in Run Mode. When I run the same test in Debug, with no breakpoints, the test passes every time. Basically, it is a socket connection test. I first disconnect a socket, and then try to reconnect, and I am trying to check if the reconnection was successful. Somewhere in...

Saving to a repository using Rhino Mocks

Hi, I have so far been coding by doing mostly Get methods in my business/service layer using Rhino Mocks to get an expected List or type and making Rhino Mocks return it for me, my question is how do I test a set/save call, e.g void SaveCustomers(Customer) I have a call called GetCustomers, can I use Rhino mocks to call this immediatel...

Bash: Execute script on file save?

I'd like to use Bash to run a test suite automatically when I save any file in a given directory. Is there a mechanism for bash to execute a given script on save events? Thanks. ::EDIT:: I should have mentioned that I'm on using OSX. ...

Rails: best way to test an action called remotely?

I was trying out Rails again, this time the 3 version, but I got stuck while writing tests for an action that I only call remotely. A concrete example: Controller class PeopleController < ApplicationController def index @person = Person.new end def create @person = Person.new(params[:person]) @person.save end end ...

Mod_python and unit testing

It there an easy way to do unit testing on an application written with mod_python? Something where I can generate dummy request objects easily. Thanks! ...

TDD for an OSX app

Are there any good solutions out there for TDD of a MacOSX Objective-c app? EDIT: more info I would really like something similar to rSpec from the Ruby world. Is the XCode built in stuff sufficient? I have heard that it is not. I would like something that supports Mocks, Stubs, and most/all of the test conditions supplied by rSpec (or...