unit-testing

WPF Unit testing framework

Is there a framework that supports UnitTesting of WPF applications. It should not be to difficult to establishe, because I don't want that writing the tests takes ten times longer than implementing a small feature. ...

J Mock it for Non Static Classes

I have a class under test which says some thing like ClassA a = new ClassA(); In this case, i want it to instantiate ClassB which is a mock of ClassA. I am using Mockit.redefine and restore .. During execution of a.doSomething() I get an error saying java.lang.NoSuchMethodError: ClassB: method ()V not found.. The method signature is ma...

.NET + TeamCity: Private Accessors Are Not Compiled

I'm running Team City Pro (v4.0.2 build 8222) for a VS2008 sln file. Right now I'm facing a problem where autogenerated code for private accessors in a test project not being generated and causes compile errors by not being able to find those (autogenerated) classes. The build runner is the default sln2008. Any configuration need to b...

Testing SQL query on Oracle which includes a remote database

Our development databases (Oracle 9i) use a remote database link to a remote shared database. This decision was made years ago when it wasn't practical to put some of the database schemas on a development machine - they were too big. We have certain schemas on the development machines and we make the remote schemas look local by using ...

NUnit 2.5 returns inconclusive state in Visual Studio

So' I'm getting in Unit Testing. I created a really simple Function to test it. public int MultiplyByFive(int x) { return x * 5; } The Test Method contains [TestMethod()] [DeploymentItem("UnitTestApp.exe")] public void MultiplyByFiveTest() { Program_Accessor target = new Program_Accessor()...

Unit testing failing due to 0.000000001f inaccuarcy.

A vector is out by 0.000000001f so the test is failing. Doing the logic in my head yeilds -1.0f, -1.0f but when I wrote the code to pass the test (Using the built in Vector methods) the answer comes back as -0.999999999f, -0.999999999f which is still 'right'. This is C# (Vector2 class provided by the XNA framework) by the way, so I tri...

Unit Testing Private Setter Question (C#)

I'm trying to test an Order entity method called AddItem and I'm trying to make sure that duplicate items cannot be added. Here is some example code: [Test] public void ItemCannotBeAddedTwiceToOrder() { Order o = new Order(); Item i = new Item("Bike"); o.AddItem(i); o.AddItem(i); Assert.AreEqual(o.ItemCount, 1, "A...

How do you make methods relying on extension methods testable?

I have an extension method with the following signature (in BuildServerExtensions class):: public static IEnumerable<BuildAgent> GetEnabledBuildAgents(this IBuildServer buildServer, string teamProjectName) { // Omitted agrument validation and irrelevant code var buildAgentSpec = buildServer.CreateBuildAgentSpec(teamProjectName);...

Using Spring to inject EasyMock mocks causes ClassCastException

I am trying to get Spring to inject EasyMock mocks in my unit tests. In my applicationContext.xml, I have this: <bean id="mockService" class="org.easymock.EasyMock" factory-method="createMock" name="MockService"> <constructor-arg index="0" value="my.project.Service"/> </bean> In my unit test I have this: @Autowired @Qualifier(...

Test project and config file

I have this kind of setup in my Visual Studio 2008 solution: One WCF service project (WCFService) which uses library (Lib1, which requires some configuration entries in app.config file). I have a unit test project (MSTest) which contains tests related to Lib1. In order to run those tests, I need a config file in test project. Is there an...

Unit test adoption

We have tried to introduce unit testing to our current project but it doesn't seem to be working. The extra code seems to have become a maintenance headache as when our internal Framework changes we have to go around and fix any unit tests that hang off it. We have an abstract base class for unit testing our controllers that acts as a t...

What is the order of execution in NUnit?

I have been doing some research on test driven development and find it pretty cool. One of the things I came across was that when you write your tests, there is an order of execution of your setup and test methods ([Setup] and [Test]). Are there others that you can use while testing and if so what is the execution order of those, suc...

Populating Models using LINQ

I'm trying to figure out a clear way of populating my model classes from LINQ to SQL generated objects. My goal is to keep my Models and LinqModels separate. Say I have the following models: public class Person { public List<Account> Accounts {get; set;} } public class Account { public List<Purchase> Purchases {get; set;} } pub...

Mocking a connection to a data source inside a function with Moq?

Hi! I'm starting to use Moq and I cannot figure out how to test the method Execute in the code below: I have the following class: public class MyObject { private IDataReaderPlugin m_source; private IDataWriterPlugin m_dest; private string[] m_dummyTags = new string[] { "tag1", "tag2", "tag3"}; public void Execute(DateT...

How to unit test a controller that calls Url.Action using AutoMockContainer?

This question is very similar to 674458 but I really want to use the AutoMockContainer in my unit tests. I cannot figure out how to setup up my context. Has anyone been able to unit test a controller that calls Url.Action using the AutoMockContainer? ...

Automated testing of authorization scenarios implemented with AzMan

I have a web application that uses AzMan authorization to grant different functionality to different users. I've just started using WatiN to implement some automated web UI tests that run under Visual Studio Team System/TFS. I'd like to be able to use it to verify the different authorization scenarios. To do this though I'd need to be ab...

Make NUnit not stop at first failure

I'm running a NUnit test over a list of numbers. My code goes something like this: numbers = GetListOfNumbers() foreach number in numbers Assert.IsTrue(TestNumber(number)) My problem is that NUnit will stop the test on the first number it encounters that doesn't pass the test. Is there anyway to make NUnit still fail the test ...

What is an ObjectMother?

What is an ObjectMother and what are common usage scenarios for this pattern? ...

Timeout problem running WatiN tests as part of TFS build

I've gotten a simple WatiN web test running on my dev environment and am trying to get it working on the TFS build server. It is failing when just trying to load a page with the following exception: WatiN.Core.Exceptions.TimeoutException: Timeout while Internet Explorer busy. I've set the test timeout to 3 minutes which should be plenty...

How to use Zend Framework 1.8 unit testing?

Hello, In Zend Framework 1.8, using Zend_Tool, the framework now generates controllers, actions, etc. automatically. What it does is that it also creates a tests directory when creating a project. quickstart |-- application | |-- Bootstrap.php | |-- configs | | `-- application.ini | |-- controllers | | |-- ErrorControlle...