tdd

Mocking FormsIdentity.Ticket.UserData with Moq

As part of a unit test I am trying to mock the return value of FormsIdentity.Ticket.UserData The following will NOT work but it should give an idea of what I am trying to do: var principal = Mock<IPrincipal>(); var formsIdentity = Mock<FormsIdentity>(); formsIdentity.Setup(a => a.Ticket.UserData).Returns("aaa | bbb | ccc"); principal.S...

How do I have a negative scenario with Cucumber in Rails?

I have a negative scenario to test with Cucumber. Specifically, I want to make sure that when someone posts a URL with an invalid handle then the site returns an error. My scenario looks like: Scenario: create person with too short a handle When person named "Fred" with handle "tooshort" updates Then I should get a 500 ...

Writing an OS for Motorola 68K processor. Can I emulate it? And can I test-drive OS development?

Next term, I'll need to write a basic operating system for Motorola 68K processor as part of a course lab material. Is there a Linux emulator of a basic hardware setup with that processor? So my partners and I can debug quicker on our computers instead of physically restarting the board and stuff. Is it possible to apply test-driven d...

Unit testing Linq 2 Sql lazy-loaded properties

Lets say I have a Customers table and an Orders table with a one-to-many association (one customer can have multiple orders). If I have some code that I wish to unit test that accesses a specific customer's orders via lazy-loading (e.g. a call to customer.Orders), how do I mock / stub that call out so that it doesn't hit the database? ...

[TDD] Testing Target-Action wiring

Hi, i came across the following blog post that explained the topic. However I do have troubles with the given samples. It verifies target-action binding like so: STAssertEquals([doSomethingButton action], @selector(doSomething:), @"The button should send -doSomething: to its target."); STAssertEquals([doSomethingButton target], _wi...

unit test installers

I am starting to do some installer work using WiX (yay, not Installshield) and I was hoping to do some TDD of the installer. Does anybody know of an easy way to do this? ...

Books that will cover TDD, DDD and Design Patterns in .NET

I would like to get book(s) that will really give me a complete view of modern ASP.NET development using C#, TDD, ASP.NET MVC, DDD and Design Patterns such as the Repository pattern. I'm very competent with C# and ASP.NET MVC, but want to fill in the gaps. If you've had a good experience with a book or two that covers these topics coul...

Unity XML Config Test

We are constantly having problem with our application being broken due to the Unity configuration not being able to resolve dependencies, either the dll or namespace has been changed or is initially wrong. Can anyone point me in the right direction for writing a Test that will ensure all the Unity config files can resolve their dependen...

Has anybody used Unit Testing as a way to learn programming?

I understand the concept of Unit Testing as coming up with simple ideas about what your code should output - then outputting it. So it's thinking about what you want a piece of code to do - then making a test to ensure it works. At which point in learning programming should TDD (unit testing) be incorporated? Edit: I liked the comment ...

If you change code that has a unit test against it, which do you change first?

I have a project that I am building that I have to change a method to behave slightly different. I have several unit tests already built against that method, but I will need to add more to cover the new behavior I am going to add to it. Is it good form to change/add those tests first before making the code change, or do you change your c...

In test driven development, do you write every possible test first, then the code?

In doing test driven development I have been in the habit of writing the first unit test for a new piece of functionality first, then writing the code for that functionality. If I have additional tests to write to cover all scenarios, I usually write them after the code is written. Is this considered bad form? Should I try and write ever...

Running Tests From a Module

I am attempting to run some unit tests in python from what I believe is a module. I have a directory structure like TestSuite.py UnitTests |__init__.py |TestConvertStringToNumber.py In testsuite.py I have import unittest import UnitTests class TestSuite: def __init__(self): pass print "Starting testting" suite = unit...

Basic NMock database examples for CRUD application

I'm looking for some basic examples of using NMock2 to mock database calls for a CRUD application. Thanks, Chris ...

Test driven development for C++ XPCOM component ?

I want to create a Firefox extension using c++ XPCOM component which in turn uses javascript XPCOM component. Is there any framework that allows test driven development of C++ XPCOM component/firefox extension ? ...

How to unit test private methods in BDD / TDD?

I am trying to program according to Behavior Driven Development, which states that no line of code should be written without writing failing unit test first. My question is, how to use BDD with private methods? How can I unit test private methods? Is there better solution than: - making private methods public first and then making th...

Career Killer? Nhibernate, OOP, Design Patterns, Domain Driven Design, Test Driven Development, IoC, MVC

I have a fairly slick approach to doing C# development using the above tools/methodologies. Specifically i follow the "Jeffrey Palermo Agile Bootcamp" onion architecture. I feel like I'm a strong developer/architect using these tools and that these make me more productive and help make more maintainable code. I think these are all imp...

Testing only the public method on a mid sized class?

Hi, I have a class called FooJob() which runs on a WCF windows service. This class has only 2 public methods, the constructor, and a Run() method. When clients call my service, a Dim a new instance of the Job class, pass in some parameters to the ctor, then call Run()... Run() will take the parameters, do some logic, send a (real time...

How do I go about setting up a TDD development process with Google App Engine?

I'm primarily a Ruby guy, but lately I've been working on a lot of Python stuff, in particular, App Engine code. In Ruby, I'd use automated continuous integration (autotest), code coverage tools (rcov), static analysis (reek), and mutation testing (heckle) in my development process, but I'm not sure how best to set up a similar developm...

Recommended thing for a TDD newbie

Hello, I'm very new to TDD world. I have a few questions regarding TDD. Do I have to do test-first in TDD? I heard that TDD is not about test. It's about design. I'm agreed that it's good to do test-first but what I like to know is that is it still TDD if we follow the test-last approach? Shall we prefer to use BDD over TDD? I used t...

What is the name of the pattern?

Hi. I often design system where I have a class in my system that has a bunch of protected methods. The protected methods are that because they should be accessible to specializations, and as such, I consider the protected methods to be a contract between my general class and any specialized classes. Therefore I want to test that these...