unit-testing

use cactus and junit 4 at the same

Is it possible to use cactus and Junit 4 at the same time? Because I know that current cactus release is based on Junit 3.8. Cactus looks like hasn't been maintained for a long time,doesn't even support annotation, is there any better framework to replace cactus? ...

Running custom SQL to prepare Rails integration test

I am trying to run some custom SQL during the setup of my Rails integration tests to prepare a legacy database (e.g., to create its tables, create any required views, etc.), which is not part of my schema.rb (nor do any migrations for it exist). Are there any best practices for doing so? Googling has not been very enlightening so far ;-...

How can I unit test a WPF StyleSelector?

I'm having trouble figuring out a way to unit test a WPF style selector. My selector looks like: public class ListViewItemStyleSelector : StyleSelector { public override Style SelectStyle(object item, DependencyObject container) { var listView = ItemsControl.ItemsControlFromItemContainer(container) as ListView; ...

How can I unit test a servlet with a request that just consists of xml content

I'm trying to unit test a java WFS web service implementation. The service can accept requests containing KVP params such as: http://www.someserver.com/wfs&amp;SERVICE=WFS&amp;VERSION=1.1.0&amp;REQUEST=GetFeature&amp;TYPENAME=InWaterA_1M or it can also accept a request containing an XML fragment such as <?xml version="1.0" ?> <...

Code Coverage report on unit tests for Windows CE code using TFS 2010

I have a unique combination of platforms in my solution that has stumped me. We need to generate code coverage statistics for unit tests that we're writing for our Windows CE code. We're using Visual Studio 2008 to write the CE code, of course, because VS 2010 doesn't support smart devices. Unfortunately, MSTest won't instrument CE ass...

Why would extending JerseyTest vs extending TestCase cause no tests to be found.

I am attempting to get the Jersey test framework working. We are building using maven 1.x. I've created the following testcase... public class SomeResourceTest extends JerseyTest { public SomeResourceTest () throws Exception { super(new WebAppDescriptor.Builder(PACKAGE_NAME) .contextPath(PATH).bu...

PHPUnit "Mocked method does not exist." when using $mock->expects($this->at(...))

I've run into a strange issue with PHPUnit mock objects. I have a method that should be called twice, so I'm using the "at" matcher. This works for the first time the method is called, but for some reason, the second time it's called, I get "Mocked method does not exist.". I've used the "at" matcher before and have never run into this. ...

Can units tests be implemented effectively with agile development?

Soon I will be involved in a project that will be using the agile project management/development approach, with 5 (or so) 2 week sprints. The project will be using a DDD design pattern which I have found in the past works great with unit testing, hence I have enthusiasim to use it for this project as well. The only problem is given the f...

Where/what to test? Mocks, stubs, functional, unit... (in Ruby/Rails)?

Hi all, I'm trying to test a fairly large Rails app, which I probably should have been doing all along but never felt entirely comfortable with. Now I'm working on a functional test to see if a user is created successfully. Basically, I'd like to test a few things: whether the user was saved (i.e., if there's a new record in the DB) ...

How do I unit test ASP.NET MVC2 model validation?

I'm using Nunit as my unit testing framework and I've created a couple of L2S entities and validation classes. Now I want to unit test the validation, but I can't figure out how to do that. This is my validation class: [Bind(Exclude = "ProjectID")] public class ProjectValidation { [Required(ErrorMessageResourceType = typeof(Valid...

Writing unit tests in Python: How do I start?

I completed my first proper project in Python and now my task is to write tests for it. Since this is the first time I did a project, this is the first time I would be writing tests for it. The question is, how do I start? I have absolutely no idea. Can anyone point me to some documentation/ tutorial/ link/ book that I can use to start...

Is there a way to unit test against side effects?

Any code can provide side effects. Most of the time, side effects can be a sign of bad design and/or need of refactorisation, but when unit testing I find it hard to test against. Consider the following example: [Test] public void TrimAll_Removes_All_Spaces() { // Arrange var testSubject = "A string with lots of sp...

How to let maven run a single test class with non-default profile activated?

I'm trying to let maven run a single test class but I need to use an additional profile (which in fact is already created). Normally when I run: mvn clean install -PmyProfile "myProfile" is being activated. So I tried: mvn -Dtest=myTest -PmyProfile test Which resulted in "[WARNING] Profile with id: 'myProfile' has not been activ...

Mocking EventLog and EventLogEntry

I'm trying to write unit tests for an application that reports on Entries in an EventLog. Right now when I run the unit tests, I'm having to create a temporary EventLog, write entries to it, and delete the log when I'm done. I'm doing this because I need to get back the EventLogEntry object, which have no constructor. My question is...

Retry a Visual Studio C# TestMethod

I'm curious to know if there's any built-in mechanism to retry tests in the Visual Studio 2008 unit testing framework for C#. Case in point, I have a C# unit test which looks something like: [TestMethod] public void MyMethod() { DoSomething(); Assert.Something(); } Now, occasionally DoSomething() performs badly; in that case I...

unit test console output

IF I am testing something related to an error, I might want to see the message or stack trace in the console initially. After I'm satisfied with the test I typically do not want to have the console cluttered with anything that might help quickly spot and diagnose a failing test. When refactoring though, it is sometimes useful to once aga...

How do I run a django TestCase manually / against other database?

I have some methods written into a django.test.TestCase object that I'd like to run from the manage.py shell on my real database. But when I try to instantiate the TestCase object to run the test method, I get this error: ValueError: no such test method in <class 'track.tests.MentionTests'>: runTest Is there a way to instantiate the...

How to test private fields that are modified via public methods

Can anyone guide me with a suggested means of testing a private field in a class that is modifed via a public method. I've read a lot of comments from people suggesting that testing private members is not advised as they are internal to the implementation, however this scenario seems to be different from most other answers. I was thinki...

how to test mail() using PHPUnit

Hello, is there a way to test with PHPUnit (or maybe other testing framework for PHP) if mail is sent correctly? I have to test a code which uses PHP function mail() . With custom mailer class i could always make a mock, but for mail() ... ? Maybe there is some plugin which is capable to use IMAP and verify if mail is received? (and it ...

First TDD test with no assert/expected exception. Is it worth it?

Let's say I'm starting to do a game with TDD. Is this a good first test? [TestMethod] public void Can_Start_And_End_Game() { Tetris tetris = new Tetris(); tetris.Start(); tetris.End(); } It basically forces me to define 3 things: the Tetris class and its Start() and End() methods, but besides that it's pretty useless. It m...