unit-testing

java.lang.IllegalStateException: missing behavior definition for the preceding method call getMessage("title")

Hi All, I'm using EasyMock(version 2.4) and TestNG for writing UnitTest. I have a following scenario and I cannot change the way class hierarchy is defined. I'm testing ClassB which is extending ClassA. ClassB look like this public class ClassB extends ClassA { public ClassB() { super("title"); } @Override ...

How do I connect StaticListableBeanFactory with ClassPathXmlApplicationContext?

In the setup of my test cases, I have this code: ApplicationContext context = new ClassPathXmlApplicationContext( "spring/common.xml" ); StaticListableBeanFactory testBeanFactory = new StaticListableBeanFactory(); How do I connect the two in such a way that tests can register beans in the testBeanFactory during...

How to keep my functions (objects/methods) 'lean and mean'

Hi, in all (Agile) articles i read about this: keep your code and functions small and easy to test. How should i do this with the 'controller' or 'coordinator' class? In my situation, i have to import data. In the end i have one object who coordinates this, and i was wondering if there is a way of keeping the coordinator lean(er) and...

Log information inside a JUnit Suite

I'm currently trying to write inside a log file the total number of failed tests from a JUnite Suite. My testsuite is defined as follows: @RunWith(Suite.class) @SuiteClasses({Class1.class, Class2.class etc.}) public class SimpleTestSuite {} I tried to define a rule which would increase the total number of errors when a test fails, bu...

What is your technology stack for developing in C++?

What is your technology stack for developing C++ applications? I'm trying to decide on one. So far this is what I have in my list: Boost Boost::Unit Testing googlemock log4cpp doxygen ant hg ...

ReSharper no longer runs unit tests

Hey folks I'm trying to write some unit tests for an app I work on at work (In the vague hope that others might follow suit), and I was originally running these tests using NUnit and the ReSharper plugin. However, ReSharper will no longer run tests for me for some reason: It simply crosses them out with a red strikeout. There's no err...

Shoulda and Paperclip testing

I am trying to test a couple models that have an attachment with Paperclip. I have all of my validations passing except for the content-type check. # myapp/test/unit/project_test.rb should_have_attached_file :logo should_validate_attachment_presence :logo should validate_attachment_size(:logo).less_than(1.megabyte) should_validate_atta...

Shoulda testing format

I am trying to test a model's attributes for formatting with this: # myapp/test/unit/comment_test.rb require 'test_helper' class CommentTest < ActiveSupport::TestCase should_belong_to :article should_validate_presence_of :name should_validate_presence_of :email should_validate_presence_of :content should_validate_presence_of...

How do I make this ASP.NET MVC controller more testable?

I have a controller that overrides OnActionExecuting and does something like this: protected override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); string tenantDomain = filterContext.RouteData.Values["tenantDomain"] as string; if (!string.IsNullOrWhiteSpace(tenantDomai...

Private Accessor for method is not found

I'm getting this error when generating a new unit test under Visual Studio 2010 using the context menu (right-click the method name -> "Generate Unit Tests"): Private Accessor for methodName is not found. Please rebuild the containing project or run the Publicize.exe manually. The method is public (checked that by applying applying a ...

Getting started with unit testing in VS2010?

I'm new to both unit testing and Visual Studio 2010 (just upgraded from 2008). I'm interested in using VS2010's new built-in unit testing tools, but would like to get the lay of the land first. I haven't been able to find any resources or tutorials on unit testing with VS2010 specifically - has anyone found a good walk-through? I'm als...

ccnet and unit testing

is it possible for ccnet to say that the build has failed in the ccnet tray and the web site if a unit test fails for the project? Anyone know of a tutorial for this? ...

How do we name test methods where we are checking for more than one condition?

I follow the technique specified in Roy Osherove's The Art Of Unit Testing book while naming test methods - MethodName_Scenario_Expectation. It suits perfectly well for my 'unit' tests. But,for tests that I write in 'controller' or 'coordinator' class, there isn't necessarily a method which I want to test. For these tests, I generate m...

[VS 2010] How to convert an existing assembly to a ms unit test assembly ?

In Visual Studio 2010 Pro, how can I easily convert a classic assembly to a ms unit test assembly ? It there a flag to activate in the .csproj file ? ...

Mocking SQL output parameter

I mocked a couple of methods of my Data Access layer, but in some methods the value of an SQL output param is set. How can I mock this ? Method: var wrappedParameters = new SqlParameter[3]; wrappedParameters[0] = new SqlParameter("@username",username); wrappedParameters[1] = new SqlParameter("@password",passwor...

Unit testing "hybrid" WPF/Silverlight controls

I'm starting a new WPF/Silverlight custom control project and wanted to do unit testing on this one. However I'm a little confused about how to approach this. This control would be based on the same codebase for both WPF and Silverlight with minor forking using #ifs and partial classes to tame the differences. I guess I could write unit...

How to copy resource (any content) files to output folder when NUnit's shadow copying is turned on?

Of course there is an option to turn it off (by default it is on.) However I like to be able to make incremental changes to the DLL while a copy of NUnit GUI is up. However I couldn't find much documentation for this feature (apart from the need) So the problem is like this With Shadow copy enabled in NUnit, my SUT (Dll) invokes an exe...

Rails "rake test" crashing

Hi, this might be rather unspecific, but I'm trying to do 'rake test' on a new rails app, and end up with (in /Users/myname/dev/railstest/RailsApplication1) /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -I"lib:test" "/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" /System/Library/Frameworks/...

C# why unit test has this strange behaviour?

I have a class to encrypt the connectionString. public class SKM { private string connStrName = "AndeDBEntities"; internal void encryptConnStr() { if(isConnStrEncrypted()) return; ... } private bool isConnStrEncrypted() { ...

Managing test data for Junit tests.

Hi, We are facing one problem in managing test data(xmls which is used to create mock objects). The data which we have currently has been evolved over a long period of time. Each time we add a new functionality or test case we add new data to test that functionality. Now, the problem is when the business requirement changes the ...