unit-testing

Designing an OO and Unit Test Friendly Query System

I'm working on an application that allows dentists to capture information about certain clinical activities. While the application is not highly customizable (no custom workflows or forms) it does offer some rudimentary customization capabilities; clients can choose to augment the predefined form fields with their own custom ones. Ther...

Unit Testing Network Connection

I am doing a unit testing and I need to find a way to simulate a disconnection during DB transactions without actually or physically removing the network cable..The process must be automated since this is just part of a bigger scale of unit testing. I need to check if roll backs are handled accordingly ...

Generating java code parse trees and evaluating it for testing

We have a need to generate Java source code. We do this by modeling the abstract syntax tree and have a tree walker that generate the actual source code text. This far all good. Since my AST code is a bit old, it does not have support for annotations and generics. So I'm looking around for open projects to use for future projects with c...

Is there a way to get which classes a ClassLoader has loaded?

I am trying to implement some unit testing for an old framework. I am attempting to mock out the database layer. Unfortunately our framework is a bit old and not quite using best practices so there is no clear separation of concerns. I am bit worried that trying to mock out the database layer might make the JVM load a huge number of clas...

Unit Testing WPF UserControls

Is it possible to test my WPF UserControls from NUnit (or similar)? If I create an instance of the usercontrol in a unit test like so: // Create an instance of the WPF UserControl var view = new ChildrenListView(); I get the following error: "The calling thread must be STA, because many UI components require this" I get the feeling...

Mocking DbProviderFactory

I am relatively new to unit testing, and completely new to mocking. I have a database class that wraps the DbProvider factory that I would like to create unit tests for without connecting to the database. How would I mock the DbProvider factory, so I could pass it in to test my class? Would I also need to mock the DbConnection, DbCo...

What is the MSTest Attribute for including a test resource?

I want to have a test resource that is available during my test and I know there is an attribute that deploys the item. What is the attribute? ...

Unit Testing Some Web Service Methods

My boss wants me to create an .aspx page, textboxes for simplicity for entering credit card information so we can test out some methods in our CreditCard service. Thats fine but I would think we could do a Unit test for this. The only thing is, instead of typing the stuff into a web form, we'd just change the variable values passed int...

What is a good ratio of refactoring time versus development time?

Hello, I'm trying to build a plan on how we could spend more time refactoring. So I wanted to compare with the industry standards but I have hard time to find studies or metrics on that. I feel that 20% of dev time spent on refactoring seems a good ratio, but I don't have anything to show for it. In my mind, for 100% or dev time: 50%...

Fail TFS Build on Single Unit Test Failure

Setting up CI within Microsoft Team Foundation Server, I have a build that will build the solution and execute all of the unit tests within the solution. Currently the build will show as partially succeded if the build is successful and an of the unit test fail. I would like to show the build as failed when a unit test fails. Can anyo...

Mocking website url thumbnailing feature in Rails?

Hi, I just started testing a new rails project, and I want a feature to webthumb the url into image. And now I want to test this feature. I'm trying to use the ThoughtBot family - shoulda factory-girl paperclip. For mocking, mocha. How can I test this feature? ...

Testing Javascript that Manipulates the DOM

I've been looking into javascript test suites and I have found QUnit to be very interesting. I understand how to test computational code, but... How do you test javascript applications written primarily for DOM manipulation? it seems like testing the position/color/etc of DOM elements would be a moot point because you'd end up doing so...

Dynamically Injecting Attribute to a Method

During unit testing I need to decorate my methods with Test attributes as shown below: [Test] public class when_1_is_passed : specifications_for_prime_test { public void should_return_false() { Assert.AreEqual(1,1); } } The [Test] attributes represents that a method is a test method. I wa...

What are some best practices for Model validation in ASP.NET MVC?

I'm not interested in answers concerning client side validation or model binding. Really, this question could apply to any data access class library outside of MVC, but the issues are similar, I think. I'm using the Repository pattern currently for data access with my entities (models). Currently the repositories handle all of the CRU...

Test Projects Won't Load in VS08

When I try to load a solution, I get the following error: The project file [filepath] cannot be opened. The project type is not supported by this installation. After hitting OK twice, my solution loads fine except for the two test projects (the [filepath] above references these two test projects), which are greyed out. When I try t...

Are there any plans for Microsoft to support testing frameworks other than MSTest?

It seems like you should be able to configure your preferred unit testing framework as a plugin to Visual Studio/Team system like you can with SourceControl providers. Is anyone aware of an effort within microsoft to allow for swapping out MStest for nUnit, mbUnit or others. Obviosly nothing prevents me from using these other frameworks...

TDD with diagrams

I have an app which draws a diagram. The diagram follows a certain schema, for e.g shape X goes within shape Y, shapes {X, Y} belong to a group P ... The diagram can get large and complicated (think of a circuit diagram). What is a good approach for writing unit tests for this app? ...

C++ Unit-Testing Framework for z/OS (IBM Mainframe)

Does anyone know of a C++ unit-testing framework (e.g. CppUnit, Google Test, etc.) that can be used to write tests on z/OS? I do most of my development on Windows using the Dignus C++ compiler, which you can use as a cross-compiler and generate object code to run on z/OS. I tried writing a sample test using Google Test, but the compile...

WPF MVVM Unit Tests for the ViewModel?

I keep reading about the benefits of using MVVM, especially for unit testing. So, now I need to write unit tests for my ViewModel. Does anyone have any examples of this? Should I just generate the unit tests using VS2008 and select those tests that appear important? ...

Cross compiling unit tests with CppUnit or similar

Has anyone used a package like CppUnit to cross-compile C++ unit tests to run on an embedded platform? I'm using G++ on a Linux box to compile executables that must be run on a LynxOS board. I can't seem to get any of the common unit test packages to configure and build something that will create unit tests. I see a lot of unit test p...