tdd

How do you unit-test a TCP Server? Is it even worth it?

I'm developing a small TCP server, which will process some TCP packets and behave differently based on the request. How can I write unit test for this? If it's really hard to write, is it even worth the effort? ...

Modify C# Class method during execution

I'd like to override a class method without inheriting the base class because it'd take a lot of time and modifications and, therefore, more and more tests. It's like this: class TestClass{ public void initialMethod(){ ... } } And somewhere on the code, I'd like to do something like this: public testMethod() { ret...

Performance testing best practices when doing TDD?

I'm working on a project which is in serious need of some performance tuning. How do I write a test that fails if my optimizations do not in improve the speed of the program? To elaborate a bit: The problem is not discovering which parts to optimize. I can use various profiling and benchmarking tools for that. The problem is using au...

How to mock Controller.User using moq

Hi there, I have a couple of ActionMethods that queries the Controller.User for its role like this Boolean isAdmin = User.IsInRole("admin"); acting conveniently on that condition. I'm starting to make tests for these methods with code like this [TestMethod] public void HomeController_Index_Should_Return_Non_Null_ViewP...

TDD and the Bayesian Spam Filter problem

It's well known that Bayesian classifiers are an effective way to filter spam. These can be fairly concise (our one is only a few hundred LoC) but all core code needs to be written up-front before you get any results at all. However, the TDD approach mandates that only the minimum amount of code to pass a test can be written, so given t...

Unit Testing a service with System libraries required

I'm currently tdding a "PluginsService" that I'm writing. I'm needing to use the System libraries of Assembly, AssemblyName, Directory and File. Currently I'm creating wrapper interfaces for each of these so I can mock them in the tests. This does mean however that I'm having to inject quite a few wrappers into the service. So for ex...

bypass dispose for testing

Hi I'm trying to test a method. I want to ensrur that there is a method call in that method (calling service) the code look like this: using(proxy = new Proxy()) { proxy.CallService(); } I swap the proxy with fake object (using TypeMock) but get error because of the fake object disposed in the end of block. I don't want to ...

Mocking non-virtual Events (In COM interop classes)

Edit: Language/Platform is C# / .Net I'm currently trying to fill a vast unit-test void in my current project, and being admittedly new to TDD, find myself quite stumped as to how to go about testing some of the more business-critical features. I picked up Moq and had an easy enough time doing simple mocks, however at the core of my ap...

Testing an object's state at save

I'm looking to write unit tests for a method such as this one: public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string newPasswordAnswer) { ISPMembershipUserDao userDao = GetISPMembershipUserDao(); if (ValidateUser(username, password)) { SPMembershipU...

TDD-friendly Singleton-like class

I have repository class that is used by at least 2 other classes. This repository class needs to be initialized - which is high in cost (querying database). Now, I create separate instances of repository wherever I need it. The thing is, that everytime I create repository it has to be initialized. How to design such repository to be TDD-...

What are the limits of TDD?

I have just recently discovered how much I enjoy developing code the TDD way: I feel I have much more control over the direction the development is going. Whereas before I spent a lot of time designing data structures and algorithms up front, now I start small and "grow" my code organically. After every red/green/refactor cycle I have co...

A software testing book from an engineering perspective?

I'm looking for a book that includes methods of testing software from a software engineering perspective. Specifically, I'm looking for a book that includes black box testing techniques (such as how to test software against different input, etc.), but also includes information about test-driven development/design, unit testing, etc. Wh...

TDD with ASP.NET MVC 1.0

Where can I find a good tutorial on TDD with ASP.NET MVC 1.0? I'd prefer a video tutorial but a text tutorial would be fine as well. I have a new project starting soon and I want to start off on the right foot. ...

What is a good sample class to demonstrate TDD?

I need to give a short presentation (2-4 hours) on Test-Driven Development and need to come up with a small class that I can build using the TDD methodology. The class has to be relatively small, but "sell" the concept of TDD. If anyone has read James Newkirk's book, Test-Driven Development for in Microsoft.Net, the Stack example is pe...

Object oriented analysis and real life OOP differences

I usually try to do TDD with not much analysis (no diagrams) before start coding. Usually I find myself spliting a class into other classes to separate concerns. I wonder if a deeper analysis would prevent that. I think that much of OO analysis can't predict some of those cases. What do you think? ...

TDD guidelines says to begin with the big scope or start from the foundations?

Which is the first test I should write when following the TDD guidelines? A test for the whole system or for the smallest core method? Example: A project should read a CSV and convert it to XML. My first test should be: Take a CSV (input) and the corresponding XML (expected) and checking if the application does the conversion correctl...

"Hello World" - The TDD way ?

Well I have been thinking about this for a while, ever since I was introduced to TDD. Which would be the best way to build a "Hello World" application ? which would print "Hello World" on the console - using Test Driven Development. What would my Tests look like ? and Around what classes ? Request: No "wikipedia-like" links to what T...

Test driven development book

What book would you recommend to learn test driven development? Preferrably language agnostic. ...

Why should I use Test Driven Development?

Duplicate: Why should I practice Test Driven Development and how should I start? Is it worth to start TDD? For a developer that doesn't know about Test-Driven Development, what problem(s) will be solved by adopting TDD? [EDIT] Let's assume that the developer already (ab)uses a unit testing framework. ...

Learning Python on Windows for TDD

I'm interested in learning python to have access to a more agile language for writing tests in my .NET projects. Is IronPython mature enough for these purposes yet? I'm content with writing tests in C#, but find dynamic languages like ruby and python very attractive. Would it be better to forgo IronPython while learning, and stick to t...