unit-testing

How Do I Mock Entity Framework's Navigational Property Intelligence?

Hi Guys, I'm attempting to test my repository using an in-memory mock context. I implement this with an in-memory Dictionary, as most people do. This implements members on my repository interface to Add, Remove, Find, etc, working with the in-memory collection. This works fine in most scenarios: [TestMethod] public void CanAddPost() ...

Unable to resolve activity for: Intent

Guys, I am having a problem in running Android unit test. I got this error when I tried to run a simple test. Here's the log: Blockquote java.lang.RuntimeException: Unable to resolve activity for: Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.wsandroid.Activities/.SplashActivity } at android.app.Instrumentati...

Using TDD with OpenXml-SDK

I have started using a TDD approach to develop a small app that reads data from Excel files. Using a repository pattern type approach I have come to a hurdle which baffles me. In order to read the Excel files, I am using the OpenXml-SDK. Now typically reading from an Excel file using the SDK requires several if not more steps to actuall...

Unit-test proxy code in Java

We want to unit-test http-proxy related code. Is there a Java package which can simulate a http proxy? ...

Is BDD a replacement of TDD?

I wonder whether BDD is a replacement of TDD? What I understand now is that in an ultimate BDD we don't have unit tests any more. Instead there are stories/scenarios/features and "test steps". And it looks like a complete replacement of TDD for me. TDD is dead? ...

How to mock a method which also belongs to the target class itself?

Let's say we are testing a class C which has 2 methods M1 and M2 where M1 calls M2 when executed. Testing M2 is ok, but how can we test M1? The difficulty is that we need to mock M2 if I'm not misunderstanding things. If so, how can we mock another method while testing a method defined in the same class? [Edit] Class C has no base cla...

Unit Testing with expected errors.

For my ColorJizz library, I'm expecting slight errors when you do multiple conversions between different color formats. The errors are all very small (i.e. 0.0001 out). What do you think I should do about these? I feel like there are 2 real options: Leave them as they are, with almost 30% of tests failing Put some kind of 'error rang...

Cannot find any coverage data (ASP.NET MVC2)

I am having some issues with getting Code Coverage working with an out-of-the-box ASP.NET MVC2 Web App VS2010 Ultimate, File > New Project > ASP.NET MVC 2 Web Application > Yes, Create unit test project with Visual Studio Unit Test. I then Rebuild All, Run All Unit Tests, Go to Code Coverage and get the following message: "Cannot find ...

iphone application unit testing problem

If followed the apple tutorial for setting up application unit tests. I have two issues with "Application Unit Tests". The first is that I get a warning running application unit tests (see below). warning: Unable to read symbols for "/Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.2.2/Symbols/Developer/Library/PrivateFrameworks...

Testing Bus.Send in an application using NServiceBus

I have this code in my app .NET application using NServiceBus: Bus.Send<IServiceStarted>(e => { e.ServiceInfo = ReadServiceInfo(); e.EventTime = DateProvider.Now; }); How would you go about unit-testing such a...

Unit Testing ASP.NET MVC Controllers with Ninject

I recently upgraded Ninject to the most recent builds to fix this issue: ninject binding issue As far as I can tell, it corrected the issue, but it seems to have messed up my controller unit tests. I now get the error that I was trying to fix when running my unit tests. The error is: Error activating ISomething More than one ma...

How to stub Python methods without Mock

I'm a C# dev moving into some Python stuff, so I don't know what I'm doing just yet. I've read that you don't really need Dependency Injection with Python. I've been told you can instantiate objects in your code and have them run the way you want, however, you can point methods on those objects to my own stubs defined in my tests - supp...

Objective-C initialize (static method) called more that once?

I have code similar to this in Objective-C: SubclassOfNSObject *GlobalVariableThatShouldNeverChange; @implementation MyClass +(void) initialize { [super initialize]; GlobalVariableThatShouldNeverChange = [[SubclassOfNSObject alloc] init]; // Change more stuff with GlobalVariableThatShouldNeverChange } @end I have this r...

How to unit test functions in a ruby script without running the script

Given a ruby script with a bunch of functions, how can you unit test the functions in the script without running the script itself? Here is an example script, and here is its unit test. For example, using require or load in my unit test causes the script to execute before the tests execute. I have many of these scripts and I really pref...

Robotium test fails with: junit.framework.AssertionFailedError: View can not be clicked!

I just got started with Robotium and tried a first very simple test, but experience some problem which I can't explain / doesn't seem logic to me. I have a TabHost with an ActivityGroup and a toggle button on each activity that's displayed in the tabhost content section. When I press the toggle button, the tab content area changes to an...

Are there unit testing for SQL queries, to measure if they run the same time after schema have changed?

I have a really heavy database, with multiple large tables, and lot of indexes. We keep constantly adding new indexes, and sometimes the old queries which ran ok at that moment, they come up to use a new index, the wrong for that query. I am wondering if there is some unit testing out there for MySQL queries, that can track if the resp...

How to unit test GUI elements?

I would like to create a custom user control, which extends the textbox in WPF, but only accepts numeric values. When the user types in a non numerical value, the textbox should not respond to the input. How can I simulate userinput to a textbox, to be able to create a unit test for this behaviour? I am using the built in test framewor...

What are "bad" attributes in unit tests?

Hi, I just read question that answered what were desirable features of unit tests, but what should be avoided? What makes a unit test "bad"? What are the worst unit tests you've seen? (For example. I remember a developer telling me he once found a test suite with plenty of methods but completely devoid of any asserts). I'm particularl...

Unit-testing multithreaded applications

Has anyone got any advice or know of any frameworks for unit-testing of multithreaded applications? ...

Python Unittest

I am using python unittest module to do a number of tests; however, it is very repetitive. I have a lot of data that I want to run through the same test over and over, checking if correct. However, I have to define a test for every one. For instance I want to do something similar to this. I know I could do it using a generator (found ...