unit-testing

Remembering to run tests before commit

We have a decent set of unit tests on our code and those unit tests run in under 2 minutes. We also use TeamCity to do a build and to run tests after each check in. However, we still get issues where a developer "forgets" to run all the tests before a commit resulting in TeamCity failure which if this check in was done at 6PM may stay b...

Testing Attribute Behavior

Hi, I’m using SharpArch with SharpArch.Contrib’s [Transaction] attribute. The Transaction attribute is added to an application service method and if an exception is thrown during that method then any changes to any domain objects are rolledback. From all appearances this works well. However, I’m writing NUnit tests to confirm that ex...

How do you design complex systems with TDD?

Similar to http://stackoverflow.com/questions/2149369/does-tdd-mean-not-thinking-about-class-design, I am having trouble thinking about where the traditional 'design' stage fits into TDD. According to the Bowling Game Kata (the 'conversation' version, whose link escapes me at the moment) TDD appears to ignore design decisions made early...

IS there any manual to correct unit test system for integrating with sfGuard auth symfony?

I've installed sfGuard plugin and now most of old tests didn't work well. They need to be authenticated to the frontend system. Is there any official decision ? ...

Friction in Settingup test using abstract classes rather than Interfaces

I have started following Test Driven Development and find it very logical and helps me a lot. I have one question 1) In lot of StackOverflow answers I have seen that people say abstract base class adds lot of friction to setup a test. If we use interfaces, there would be less friction. What I am thinking is, if there is no default ...

Is there a way to have Test::Class's "Tests" subs always act like Test::More's subtests?

Right now when i do something like this: use strict; use warnings; package My::Test; use parent 'Test::Class'; use Test::More; sub overrides_basic : Tests { ok( 1, "works" ); ok( 1, "works" ); } sub overrides_no_profile : Tests { ok( 2, "works" ); ok( 2, "works" ); } __PACKAGE__->runtests; 1; The output is this: ok 1 - work...

How do I go about unit testing view models in the MVVM-Light framework?

My specific question is when the viewmodel constructor is modeled after the MVVM-Light examples, like this one public MainViewModel() { if (IsInDesignMode) { BackgroundBrush = new SolidColorBrush(Colors.Orange); } else { Messenger.Default.Register<Brush>( this, true, ...

Is it valid to have unit tests with only an assert statement?

So, i'm new to unit testing, and even more so to test first development. Is it valid for me to have just a single assert.isTrue statement in my unit test where I pass in my method and a valid parameter, and compare it to the known good answer? Method public static string RemoveDash(string myNumber) { string cleanNumber = m...

How to only throw exception when the mocked method is called for the first time?

I have a method of a mocked object that can be called multiple times (think recursion). The method is defined like this: public void doCommit() { } In order to tell it to fail I use this convention: doThrow(new RuntimeException()).when(mMockedObject).doCommit(); This though, makes the method throw this exception EVERY time it is ca...

Converting NUnit Test Project to MS Test

Hello, Has anyone tried to replace NUnit tests with MS Test, and would be willing to share any tips or points about the complexity? I was considering this, but I have a lot of tests, so outside of assembly/type switching/attribute replacement and all, any pointers? Thanks. ...

OCUnit wants me to install Rosetta

I followed the instructions on Unit Testing objective C from Apple: http://developer.apple.com/tools/unittest.html I installed the latest version of OCUnit, but when I compile, software update starts and tells me I need to install Resetta. What's going on? ...

howto hide firefox add-on popup initiate by selenium rc ?

everytime i test my selenium test, the instant of firefox will popup and show page of selenium rc. It's ok and cool. But i have problem. For every test i also have to see a firefox's page pop up and shown selenium plugin have been add to firefox. is there any way to configure selenium so it initiate firefox without a popup page cause af...

Does the self-shunt testing pattern violate the Single Responsibility Principle?

I've used the self-shunt unit testing pattern a few times over the years. As I was explaining it to someone recently they argued that it violated the SRP. The argument is that the test class can now be changed for one of two reasons: when the test changes, or when the method signature on the interface that the test is implementing change...

Why NHibernate auto-truncates instead of throwing an exception on save?

Hi, I have been studying the Summer Of NHibernate Tutorials and when I have reached the Session 04: Exploring Transactions and Concurrency -just like in the tutorial- I wanted to create a SAVE test which should fail because of an invalid object. The purpose is to test if it can rollback the transaction properly. Idea is to create an i...

Fixtures in JUnit and file structure

I'm building a card game which is only relevant because of the examples given below. I consider myself a fairly experienced C++ programmer, with considerable TDD experience in that language; most recently using UnitTest++. I am new to Java, and intend to target Android once I get my Java legs. What I want to do is something akin to th...

ASP.NET MVC 2 Unit Testing Stange Errors

I am working through the book Professional ASP.NET MVC 2 and I am trying to get the unit testing in chapter 1 to work correctly; howver, I am getting some very strange errors. There are two projects in the solution: NerdDinner, and NerdDinner.Tests. In the NerdDinner Project I have the following interface: IDinnerRepository.cs //... ...

Publicize.exe exits with error "Value cannot be null. Parameter name : interfaceType

Hi, I'm trying to make private accessor class using Visual Studio 2010. Here is the return of Publicize.exe: Error occurred during processing of assembly xxx Value cannot be null. Parameter name: interfaceType I use internals and InternalVisibleTo in my project. Perhaps that is the cause of the problem? ...

Socket not registering when the other end is closed.

I'm working on a client/server application where the connections from the client to the server stay open until the client application is closed. If the server application goes down unexpectedly, while the client is reading data, I want the client to treat this as an exception, but then to catch the exception and raise an event with the ...

seam test fails when running with @Depends

I have a MDB marked with @Depends making it dependent on my war, when I deploy the application to the server it works ok, but when I try to run my tests the test fails...seams because of some wrong config...any hints to solve this? I guess that the embeded jboss handels this in some diferent way? I use: seam 2.2.1 jboss 5.1 testNG the ...

Email notification on success/failed build using ant target.

Hi all, my current code(build.xml) enables me to send email on successful build, but when failed, nothing happens. The targets are called from a build.bat file through command similar to " ........ -DrepositoryAddress=%1 -DbuildResultUUID=%2 startPublish " (for all targets, in order startActivity->startPublish->mailer->startActivity). N...