unit-testing

Xcode Unit Testing - Accessing Resources from the application's bundle?

I'm running into an issue and I wanted to confirm that I'm doing things the correct way. I can test simple things with my SenTestingKit tests, and that works okay. I've set up a Unit Test Bundle and set it as a dependency on the main application target. It successfully runs all tests whenever I press cmd+B. Here's where I'm running i...

TDD approach for complex function

I have a method in a class for which they are a few different outcomes (based upon event responses etc). But this is a single atomic function which is to used by other applications. I have broken down the main blocks of the functionality that comprise this function into different functions and successfully taken a Test Driven Developme...

Access inner function variables in Javascript

In many frameworks, internal function variables are used as private variables, for example Raphael = (function(){ var _private = function(a,b) {return a+b;}; var _public = function(a) {return _private(a,a);} var object = {mult2:_public}; return object; })(); here, we cannot access from the global namespace the variable...

Unit testing with Data Access Layer

Hi, what is a good way to write unit tests with a LINQ to SQL DAL? Currently I am doing some database testing and need to create helper methods that access the database, but I don't want those methods in my main repo's. So what I have is two copies of the DAL, one in my main project and one in the Test project. Is it easier to manage ...

Visual Studio 2008 Unit test does not pick up code changes unless I build the entire solution

Here's the scenario: Change my code: Change my unit test for that code With the cursor inside the unit test class/method, invoke VS2008's "Run tests in current context" command The visual studio "Output" window indicates that the code dll and the test dll both successfully build (in that order) The problem is however, that the unit t...

Is this a good way to setup Moq to return a particular value only a certain number of times?

Using NUnit and Moq, I am trying to wrap some tests around legacy code before I do too much more refactoring. I need to test that a method keeps looping until told to stop. Here is my idea how to do it: [TestCase] public void KeepsCallingDoSomethingUntilShouldIKeepGoingIsFalse() { var dal = new Mock<IDataAccessLayer>(); var sut = ...

Visual C++ overrides/mock objects for unit testing?

When I'm running unit tests, I want to be able to "stub out" or create a mock object, but I'm running into DLL Hell. For example: There are two DLL libraries built: A.dll and B.dll -- Classes in A.dll have calls to classes in B.dll so when A.dll was built, the link line was using B.lib for the defintions. My test driver (Foo.exe) is te...

What command line options are available for test/unit in ruby 1.9.1?

What command line options are available if you're using the Test::Unit compatibility layer in ruby 1.9.1? Background: ruby test/test_all.rb --help provides information on what command line options are available in ruby 1.8.7, but not in ruby 1.9.1 without the test-unit gem. Looking under Test and Test::Unit for ruby 1.9.1 rdoc doesn'...

Using Assert to compare two objects

Hi everyone, Writing test cases for my project, one test I need is to test deletion. This may not exactly be the right way to go about it, but I've stumbled upon something which isn't making sense to me. Code is like this: [Test] private void DeleteFruit() { BuildTestData(); var f1 = new Fruit("Banana",1,1.5); var f2 = new...

Using Moq callbacks correctly according to AAA

I've created a unit test that tests interactions on my ViewModel class in a Silverlight application. To be able to do this test, I'm mocking the service interface, injected to the ViewModel. I'm using Moq framework to do the mocking. to be able to verify bounded object in the ViewModel is converted properly, I've used a callback: [T...

Problem while executing test case in VS2008 test project

Hi all I have the situation as follows I have develpoed one test project in visual studio 2008 to test my target project. I was getting the following exception when i ran test case in my PC System.IO.FileNotFoundException: The specified module could not be found. (Exception from HRESULT: 0x8007007E) at System.Reflection.Assembly._n...

How to create unit test for Silverlight socket server?

How to create a unit test for a Silverlight socket server? I am using the Silverlight UnitTest framework. Edit: I have a simple socket server, which listens for messages. When a message is receive, the server responds to the client. The client is in Silverlight. How can I create a unit test to check if the server response is correct?...

Test Views in ASP.NET MVC2 (ala RSpec)

Hi, I am really missing heavily the ability to test Views independently of controllers. The way RSpec does it. What I want to do is to perform assertions on the rendered view (where no controller is involved!). In order to do so I should provide required Model, ViewData and maybe some details from HttpContextBase (when will we get rid ...

Informational messages in python unit testing

I'm using Python's unittest module for unit testing. I'd like to be able to report informational messages as part of the unit test output—other than pass/fail status. Specifically in my case, I want to report whether the module under test is using the pure Python implementation or the C extension. Is there a mechanism in unittest to ou...

Loading .eml files into javax.mail.Messages

I'm trying to unit test a method which processes javax.mail.Message instances. I am writing a converter to change emails which arrive in different formats and are then converted into a consistent internal format (MyMessage). This conversion will usually depend on the from-address or reply-address of the email, and the parts of the emai...

Help configuring MSpec

rig: win7 64bit, vs2010, mvc v2, TestDriven.Net 3.0, Reshaper 5.0, MSpec 0.3 i recently started a new project and want to use mspec. (1) copied Machine.Specifications.ReSharperRunner.5.0.dll and Machine.Specifications.dll to JetBrains\ReSharper\5.0\Bin\Plugins\Machine.Specifications (2) copied Machine.Specifications.TDNetRunner.dll to...

How to do test-first development with MVVM

How do you build WPF MVVM applications and user controls test-first? I find myself writing ungodly amounts of XAML with DataTemplates before I even get to unit-testing my viewmodels. Should I develop the whole viewmodel system first before even writing XAML for it? Any help appreciated. ...

Unit testing a functions whose purposes is side effects

How would you unit test do_int_to_string_conversion? #include <string> #include <iostream> void do_int_to_string_conversion(int i, std::string& s) { switch(i) { case 1: s="1"; break; case 2: s="2"; break; default: s ="Nix"; } } int main(int argc, char** argv){ std::string...

@ContextConfiguration in Spring 3.0 give me No default constructor found

I have already do the test using AbstractDependencyInjectionSpringContextTests and it works but in spring 3 it is deprecated, so I decided to try @ContextConfiguration but spring say that default constructor is not found, I check and the class doesn't have any constructor. If I use this test spring give the object. package atoms.portal...

Django Test Failing

Hello all! I am experiencing an error running django unit tests, I've not experienced this before, and have been googling it all afternoon. I am getting this error in terminal after running django manage.py test: Error: Database test_unconvention couldn't be flushed. Possible reasons: * The database isn't running or isn't configured...