unit-testing

What am I doing wrong this time with Moq?

Hi I am having problems with moq again and not sure what I did wrong this time. So I am going through the debugger step by step and I notice even though in my Mock I set ResetPassword to return "hey it does not seem to Here is part of my unit test: var membershipMock = new Mock<MembershipProvider>(); var user = new Mo...

Why not hit the database inside unit tests?

Hi I've read in blogs that the database should not be hit when the unit tests run. I understand the theory, however say i have complex store procedures that are part of a business domain operation. I want to write a set of unit tests for the code related to the business operation, however if i mock the database i have the feeling that im...

Numerical regression testing

I'm working on a scientific computing code (written in C++), and in addition to performing unit tests for the smaller components, I'd like to do regression testing on some of the numerical output by comparing to a "known-good" answer from previous revisions. There are a few features I'd like: Allow comparing numbers to a specified tole...

How can I see what actually happens when a Test::Unit test runs?

In a Rails application I have a Test::Unit functional test that's failing, but the output on the console isn't telling me much. How can I view the request, the response, the flash, the session, the variables set, and so on? Is there something like... rake test specific_test_file --verbose ...

Reducing defect injection rates in large software development projects

In most software projects, defects originate from requirements, design, coding and defect corrections. From my experience the majority of defects originate from the coding phase. I am interested in finding out what practical approaches software developers use to reduce defect injection rates. I have seen the following appraoches used w...

unit test smell

I am trying to change my unit testing of ArcGIS, and start using mocks (I use rhino). When I started to get into writing the tests, I noticed I have to start mocking a lot of objects, and stub a lot of methods for even a single test to pass. For example - my controller first gets a RelationshipClass (so I need to stub the IWorkspace and ...

How do I make a mockup of System.Net.Mail MailMessage?

Hi So I have some SMTP stuff in my code and I am trying to unit test that method. So I been trying to Mockup MailMessage but it never seems to work. I think none of the methods are virtual or abstract so I can't use moq to mock it up :(. So I guess I have to do it by hand and that's where I am stuck. *by hand I mean witting the inter...

unit tests in C++

Is okay to break all dependencies using interfaces just to make a class testable? It involves significant overhead at runtime because of many virtual calls instead of plain method invocations. How does test driven development work in real world C++ applications? I read Working Effectively With Legacy Code and fond it quite useful but do...

Testing Quartz CronTrigger trigger

Assuming that I have a CronTriggerBean similar to <bean id="midMonthCronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> <property name="jobDetail" ref="reminderJobDetail" /> <property name="cronExpression" value="0 0 6 15W * ?" /> </bean> What is the best way to test that this bean will actually trigger...

Unit testing factory methods which have a concrete class as a return type

So I have a factory class and I'm trying to work out what the unit tests should do. From this question I could verify that the interface returned is of a particular concrete type that I would expect. What should I check for if the factory is returning concrete types (because there is no need - at the moment - for interfaces to be used)...

Unit Testing Embedded Software

What best practices have you used in unit testing embedded software that are peculiar to embedded systems? ...

Rails unit testing gone completely wrong

I don't know what and when happend on my code but I got hundereds similar erros (not failures) of this : NameError: uninitialized constant ActiveSupport::Callbacks::Callback::NORMAL And my tests function just go useless now, as even I put something like: should "failed" do assert false end It still returns passed, any idea ? ...

RSpec controller testing - blank response.body

I am stuck with a problem when testing my controllers with RSpec - the response.body call always returns an empty string. In browser everything renders correctly, and cucumber feature tests seem to get it right, but RSpec fails each and every time. Other expectations on the response object, such as response.should render_template('index...

Visual Studio's testing tools compared to third-party tools

How do Visual Studio's testing tools compare to third-party frameworks like NUnit? Are there any significant differences? ...

Linking Classes to their relative Configuration / Setup / Data in Sql and Testability

Suppose I have several services represented by classes ServiceA, ServiceB, ServiceC etc. These services have configuration and other data in SQL, in for example a ServiceConfiguration table. Are there any best practices for linking ServiceA to it's corresponding configuration and data in SQL other than hard-coding the Id in the class? ...

Test Cases: Mocking Database using Spring beans

Our application has a service layer and a DAO layer, written as Spring beans. While testing the Service Layer- I do not want to depend upon a real database so I am mocking that by creating a 'Mock' Impl for the DAO layer So when I am testing the Service layer- I chain the Service layer beans to the Mock DAO beans And in Production- wil...

Why would I *not* collect code-coverage data in unit tests, in VS2008?

If I'm running a suite of tests, is there a reason I would NOT want to collect code coverage data for the tests? What's the expected cost, in terms of runtime, storage, or anything else? I'm trying to decide if I would ever want to run with code coverage data collection OFF. ...

How do you stub an individual method in java for unit testing?

I've got a method in a class that's writing to some string, which calls another method which does the same. Something like: void foo() { a += "xyx"; bar(); } void bar() { a += "abc"; } For unit testing purposes, I want to test foo and bar separately. Is there any way to prevent bar from being run when I call foo() or to replace...

Is it legally negligent to not use unit testing

Is anyone aware of any legal precedents where the lack of unit testing in an application has lost someone a case Or where someone has not been deemed negligent despite a lack of unit testing in an application. Is there any highly regarded alternative to unit-testing that enables programmers to objectively demonstrate a committment to sof...

What should a "unit" be when unit testing?

On Proggit today I was reading the comment thread on a submission entitled, "Why Unit Testing Is A Waste of Time". I'm not really concerned with premise of the article so much as I am with a comment made concerning it: The stem of the problem is that most “units” of code in business software projects are trivial. Change the s...