unit-testing

phpUnit - mock php extended exception object

I'm testing some legacy code that extends the default php exception object. This code prints out a custom HTML error message. I would like to mock this exception object in such a way that when the tested code generates an exception it will just echo the basic message instead of giving me the whole HTML message. I cannot figure out a w...

How to unit test my project against different versions of external dll api?

I am developing an app that relies heavily on an external dll, my app needs to support new versions of the dll as well as being backwards compatible with the old ones. Are there any good ways to have my unit tests target all of these different dll versions without the need to rewrite the tests as soon as a new version of the api is rel...

How to keep your unit tests simple and isolated and still guarantee DDD invariants ?

DDD recommends that the domain objects should be in a valid state at any time. Aggregate roots are responsible for guaranteeing the invariants and Factories for assembling objects with all the required parts so that they are initialized in a valid state. However this seems to complicate the task of creating simple, isolated unit tests a...

Silverlight unit testing. Error while running tests.

I'm using VS2010. Silverlight 4, NUnit 2.5.5, and TypeMock TypemockIsolatorSetup6.0.3.619.msi In the test project MVVM is implemented, PeopleViewModel is a ViewModel which I want to test. Please advise if you use other products for unit testing of MVVM Silverlight. Or please help to win this TypeMock. TIA This is the code of the test:...

NUnit, is it possible to continue executing test after Assert fails?

In a test that contains some asserts, for example: Assert.AreEqual(1,1); Assert.AreEqual(2,1); Assert.AreEqual(2,2); is it possible to let the test keep running after it fails at some point? In the example, first condition is true, second fails and the test stops. I'd like to evaluate also the following condition. ...

How to get selenium to wait for ajax response?

How can I get selenium to wait for something like a calendar widget to load? Right now I am just doing a Thread.sleep(2500) after exporting the testcase to a junit program. ...

JUnit terminates child threads

Hi to all, When i test the execution of a method that creates a child thread, the JUnit test ends before the child thread and kills it. How do i force JUnit to wait for the child thread to complete its execution? Thanks ...

How to get selenium to click on an object other than by ID

So here is a little challenge. I have an image. It has 2 attributes: a random ID - not helpful an image url - but it is a button, and other buttons use the same image url, not helpful a CSS class - also used by too many other things to be helpful a style - neither helpful nor unique This image is however inside of an anchor tag, but ...

How can you unit test a DelegateCommand

I am trying to unit test my ViewModel and my SaveItem(save, CanSave) delegate command. I want to ensure that CanSave is called and returns the correct value given certain conditions. Basically, how can I invoke the delegate command from my unit test, actually it's more of an integration test. Obviously I could just test the return val...

VerifyError When Running jUnit Test on Android 1.6

Here's what I'm trying to run on Android 1.6: package com.healthlogger.test; public class AllTests extends TestSuite { public static Test suite() { return new TestSuiteBuilder(AllTests.class).includeAllPackagesUnderHere().build(); } } and: package com.healthlogger.test; public class RecordTest extends AndroidTes...

Problems using User model in django unit tests

I have the following django test case that is giving me errors: class MyTesting(unittest.TestCase): def setUp(self): self.u1 = User.objects.create(username='user1') self.up1 = UserProfile.objects.create(user=self.u1) def testA(self): ... def testB(self): ... When I run my tests, testA will...

How can this Ambient Context become null?

Can anyone help me explain how TimeProvider.Current can become null in the following class? public abstract class TimeProvider { private static TimeProvider current = DefaultTimeProvider.Instance; public static TimeProvider Current { get { return TimeProvider.current; } set { if (...

Naming Unit Tests that just calls a constructor?

I'm trying to follow Roy Osherove's UnitTests naming convention, with the naming template: [MethodName_StateUnderTest_ExpectedBehavior]. Following this pattern. How would you name a test calling a constructor? [Test] public void ????() { var product = new Product(); Assert.That(product, Is.Not.Null); } ...

Is there an MSTest equivalent to NUnit's Explicit Attribute?

Is there something like that in MSTest? Thanks ...

Unit Testing Model Classes that inherit from NSManagedObject

So...I'm trying to get unit tests set up in my iPhone App but I'm having some issues. I'm trying to test my model classes but they inherit directly from NSManagedObject. I'm sure this is a problem but I don't know how to get around it. Everything is building and running as expected but I get this error when calling any method on the...

Unit Testing, IDataContext and Stored Procedures via Linq

hey folks, I'm currently using Stephen Walther's approach to unit testing Linq to SQL and the datacontext (http://stephenwalther.com/blog/archive/2008/08/17/asp-net-mvc-tip-33-unit-test-linq-to-sql.aspx) which is working a treat for all things linq. My Dal layer takes in an IDataContext, I use DI (via Unity) to concrete that up as the ...

How to override the behavior of Spring @Autowired

Hi a little background: I am Using Spring 2.5, and specifically spring IOC and annotations. I am using @Autowired in my code (the Autowiring is done by type) and use @Component for exposing Classes to the Automatic wiring. The situation described bellow arose while i tried to test my code. now to the problem: Note: i use a differe...

Why should I be using testing frameworks in PHP?

Hi everyone, I have recently heard a lot of people argue about using PHP testing features like PHPunit and SimpleTest together with their IDE of choice (Eclipse for me). After googling the subject, I have still a hard time understanding the pros and cons of using these testing frameworks to speed up development. If anyone could explain...

Where do you put your unit test?

I have found several conventions to housekeeping unit tests in a project and I'm not sure which approach would be suitable for our next PHP project. I am trying to find the best convention to encourage easy development and accessibility of the tests when reviewing the source code. I would be very interested in your experience/opinion reg...

Visual Studio 2010 and Test Driven Development

I'm making my first steps in Test Driven Development with Visual Studio. I have some questions regarding how to implement generic classes with VS 2010. First, let's say I want to implement my own version of an ArrayList. I start by creating the following test (I'm using in this case MSTest): [TestMethod] public void Add_10_Items_Remove...