unit-testing

mocking collection behavior with Moq

Hello, I've read through some of the discussions on the Moq user group and have failed to find an example and have been so far unable to find the scenario that I have. Here is my question and code: // 6 periods var schedule = new List<PaymentPlanPeriod>() { new PaymentPlanPeriod(1000m, args.MinDate.ToString()), new PaymentPla...

Using PHPUnit to test cookies and sessions, how?

With PHPUnit it's quite easy to test raw PHP code, but what about code that heavily relies on cookies? Sessions could be a good example. Is there a method that doesn't require me to setup $_COOKIE with data during my test? It feels like a hacky way of doing things. ...

Need to use Unit testing famework for testing J2EE Components like Servlets , Filters and JPA.

I need to create unit tests for J2EE components like Servlets, Filters and JPA code which would call it's life cycle methods automatically and would integrate with Maven2 and Continuum and can be run from IDE itself. Can you suggest something? Thanks, Vaibhav ...

strerror_r returns trash when I manually set errno during testing

During testing I have a mock object which sets errno = ETIMEDOUT; The object I'm testing sees the error and calls strerror_r to get back an error string: if (ret) { if (ret == EAI_SYSTEM) { char err[128]; strerror_r(errno, err, 128); err_string.assign(err); } else { err_string.assign(gai_strerror...

unit testing methods with arrays as argument

I am porting over some C++ assembly to VB that performs demodulation of various waveforms. I decided to go the unit test route instead of building a test app to get a feel for how testing is performed. The original demodulation code accepts an array that is the waveform along with some other arguments. How should one go about performi...

Show MFC GUI from UnitTest in Visual Studio 2008

I have two projects in my solution. One is a MFC project which shows a simple GUI saying "Hllo World" If I compile the MFC Application Project as Application (exe) it runs without problems. What I want to do now is to show the window from my UnitTest. (Doesn't make much sens, but it has to be like that). Therefore the MFC application i...

How do I set up gaeunit 2.0a with my Django app?

I am trying to set up Google App Engine unit testing for my web application. I downloaded the file from here. I followed the instructions in the readmen by copying the directory gaeunit into the directory with the rest of my apps and registering 'gaeunit' in settings.py. This didn't seem sufficient to actually get things going. I als...

Zend Framework: How to start PHPUnit testing Forms?

I am having trouble getting my filters/validators to work correctly on my form, so I want to create a Unit test to verify that the data I am submitting to my form is being filtered and validated correctly. I started by auto-generating a PHPUnit test in Zend Studio, which gives me this: <?php require_once 'PHPUnit/Framework/TestCase.php...

Unit Testing in ASP.NET MVC: Minimising the number of asserts per test

I'm trying out TDD on a greenfield hobby app in ASP.NET MVC, and have started to get test methods such as the following: [Test] public void Index_GetRequest_ShouldReturnPopulatedIndexViewModel() { var controller = new EmployeeController(); controller.EmployeeService = GetPrePopulatedEmployeeService(); var actionResult = (Vi...

How should a unit test be written to verify a WCF-RIA Services DomainService query method requires authentication?

I'm doing unit testing for our WCF RIA services, which have RequiresRole or RequiresAuthentication attributes attached to them. I've been able to test the Update, Insert, and Delete methods to ensure the attributes are properly set. This is done by mocking a IServiceProvider, creating a DomainServiceContext with that provider and the cor...

Which is the best isolation framework for Java? JMock, Easymock, Mockito, or other?

I realize this has been asked before, but the last time was in mid 2008. If you were starting a new project right now, which one would you use and why? What are their strengths/weaknesses regarding readability, usability, maintainability, and overall robustness? ...

where to put the unittest for library in rails

Hello, I am a ruby and rails newbie. And I am working on a rails application with RadRails. RadRails has a "Switch to Test" function for my controller, model, etc. but not for my library. if I have class Foo::Bar in /lib/foo/bar.rb, where should I put the unittest for it? or should I separate the foo library in a separated project? Th...

TFS, testing and placement of test files (where)

Hi, I am currently experimenting with TFS, and I really like it. One small question, regarding test files: I have a directory with some demo TXT, images, dirs... These are used during tests, so up until now, the path was hardcoded to a folder on my computer. Now I need to change this, of course, the TFS need access to the files too. My...

ActiveMQ ignoring persistent=false

I am using Active MQ for integration testing my application. I have defined an active-mq broker in a spring config like so: <amq:broker useJmx="false" persistent="false" deleteAllMessagesOnStartup="true" useShutdownHook="true"> <amq:transportConnectors> <amq:transportConnector uri="tcp://...

Strategies for testing reactive, asynchronous code

I am developing a data-flow oriented domain-specific language. To simplify, let's just look at Operations. Operations have a number of named parameters and can be asked to compute their result using their current state. To decide when an Operation should produce a result, it gets a Decision that is sensitive to which parameter got a val...

Seeding repository Rhino Mocks

I am embarking upon my first journey of test driven development in C#. To get started I'm using MSTest and Rhino.Mocks. I am attempting to write my first unit tests against my ICustomerRepository. It seems tedious to new up a Customer for each test method. In ruby-on-rails I'd create a seed file and load the customer for each test. It se...

Understanding how software testing works and what to test.

Intro: I've seen lots of topics here on SO about software testing and other terms I don't understand. Problem: As a beginner developer I, unfortunately, have no idea how software testing works, not even how to test a simple function. This is a shame, but thats the truth. I also hope this question can help others beginners developers t...

Circular references when I create my own Unity wrapper

Hi, I've just started an MVC 2.0 solution using Unity 2.0. I thought it would be a good idea to create my Unity Container with all the RegisterType calls within a separate assembly to allow me to reuse it throughout my Unit Tests. However, I quickly realised I'd end up with circular references regardless of unit testing. My MVC appli...

TestContext is null

Pretty simple test: [TestClass] public class MyTestClass { private TestContext _testContext; protected TestContext TestContext { get { return _testContext; } set { _testContext = value; } } [TestMethod] [HostType("ASP.NET")] [UrlToTest("http://localhost/MyPage.aspx")] public void TestMyPa...

Is there value in unit testing auto implemented properties

It seems exceptionally heavy handed but going by the rule anything publicly available should be tested should auto-implemented properties be tested? Customer Class public class Customer { public string EmailAddr { get; set; } } Tested by [TestClass] public class CustomerTests : TestClassBase { [TestMethod] public void Ca...