tdd

Can we come up with a better name for TDD?

I keep hearing how Test Driven Development is an unfortunate name for the technique because TDD is not about Testing, it's about design. Personally, I've never had a problem with the name simply because I've always thought about it more as a way to program to a specification. I've never had a problem with the fact that the code that i...

Can any one suggest a step by step example for using moQ framework

Can any one suggest a step by step example for using moQ framework. any guidelines or thumbrules that has to be followed while mocking objetcs . can be much help. thanks. ...

How do I assign shortcut to "exec my entire unit test project" in Visual Studio 2008 Professional Edition

Hi all, Attempting to do TDD, I often need to execute all my tests - in my case a single test project that tests all my assemblies. Currently I'm selecting the project in solution explorer, then pressing a shortcut to "run all tests in debug mode" (which effects the current selection in solution explorer or in code window). Can I do t...

NUnit+Moq Throwing Exception

The code under test follows. view.QueryResultsGrid is a System.Windows.Forms.DataGridView object: public void SelectCheckedChanged(object sender, EventArgs e) { view.QueryResultsGrid.SelectionMode = DataGridViewSelectionMode.ColumnHeaderSelect; } Test being attempted: private Mock<IQueryForm> mockWind...

Unit Test Help. How do I test for a message output to console?

I am a newbie to unit testing. How do I check the for console output? I have namespace XXShapes { public abstract class XXShape { public virtual void DrawXXShape() { Console.WriteLine("The XXShape was drawn."); } } public class XXCircle : XXShape { public override void DrawXXShape() ...

Best way to structure your Unit Test assemblies?

I would like to optimize my unit test assemblies. Specifically, I would like to make sure that multiple developers can work concurrently without stepping on each others' toes. What is the best practice when creating unit tests? One unit test class per real class, unit tests broken up by concern rather than by class, one large unit test c...

Using RhinoMocks, how do you mock or stub a concrete class without an empty constructor?

Mocking a concrete class with Rhino Mocks seems to work pretty easy when you have an empty constructor on a class: public class MyClass{ public MyClass() {} } But if I add a constructor that takes parameters and remove the one that doesn't take parameters: public class MyClass{ public MyClass(MyOtherClass instance) {} } I...

Spawning a separate process from within a unit test

I have some unit tests (yes, perhaps more integration-ey tests !) that I would like to spin up another jvm, and then run the test code from that "other" JVM (and wait for it to finish, collecting the results). Am interested if there is an easy/reliable way of doing that with junit (eg inherit the classpath of what is needed etc...) Any...

What to do when a new feature causes existing unit tests to become invalid?

I'm building a new application and trying to adhere to "test-first" development as faithfully as I can. I'm finding myself in situations where I need to implement/change a feature that has an effect of invalidating a number of existing unit tests. How should I be dealing with this? As I see it, there are 3 options: Update or remove all...

PHP: string parameter to __construct not passed correctly.

Hi! I'm trying my hand at TDD with PHP and am writing a webbased app to access articles in a MySQL database; this is the test function: class TestArticleTestCase extends UnitTestCase { ... public function testArticleGenerateInsertSqlString() { $testArticle = new Article("12345", "2009-09-13 20:20:20", "Test heading", "Test text")...

State/Interaction testing and confusion on mixing (or abusing) them

Hello, I think understand the definition of State / Interaction based testing (read the Fowler thing, etc). I found that I started state based but have been doing more interaction based and I'm getting a bit confused on how to test certain things. I have a controller in MVC and an action calls a service to deny a package: public Acti...

TDD in an large project: How do you get started?

Simple question. Let's put on our engineer/project manager hat for a second: You have a large project and you will have several different developers working on different parts. You have a solid functional spec and are ready to start figuring out your implementation. You want to practice Test Driven Development. Assume you will be given...

"autotest/rails [...] doesn't [...] exist. Aborting"

I'm finding that autotest has stopped working... $ autotest loading autotest/rails Autotest style autotest/rails doesn't seem to exist. Aborting. According to this blog post, the common reason for this error is that people don't have the autotest-rails gem installed. However, I definitely have that installed: autotest-rails (4.1.0) Z...

How to ensure that the view is safe of null exceptions

I have in the controller a custom DataView object that comprises 2 lists. I populate them and than pass the DataView object as model for my view. In view when displaying the data I am checking for null reference. I wonder how to write unit tests to ensure that the programmer did not forget to check for null reference in the view. I would...

how can we mock static , read only members , and functions that reside within the same class?

I'm using MOQ with tdd, i'm comfortable with the simple mock objects. Now moving on to the complex objects(i.e., objects containing other objects as properties ). i have problem creating mocks for three scenarios. when the method being tested wraps a static method. when the method being tested wraps a read only property. when the metho...

Does anyone have a short document about unit tests for devs new to unit testing?

I've been tasked with writing a short document about unit testing. Basically guidance for devs who are required to write unit tests for the first time, and are somewhat unfamiliar with it. My first response was sure I can do that, but realized that there are whole books dedicated to the subject. I'm not quite sure how to distill the top...

Bash and Test-Driven Development

When writing more then a trivial script in bash, I often wonder how to make the code testable. It is typically hard to write test for bash code, due to the fact that it is low on functions that take value and return a value, and high on functions that check and set some aspect in the environment, modify the file-system, invoke a program...

In migrating from Java to C# what should I know about accessor classes

I am a Java programming now also writing in C#. I have seen Accessor classes generated by the VS test generating software (to give access from Tests to private members or functions). Should I be creating Accessors deliberately and if so why ...

Code Design / Testability How To?

My team is designing a library that is wrapping calls to Active Directory to search and return a list of people. We have a person class that wraps up the information for a person found. We then use the List to wrap them up. When we call the search it uses the internal System.Directory library and returns a SearchResultCollection objec...

How to develop complex methods with TDD

A few weeks ago I started my first project with TDD. Up to now, I have only read one book about it. My main concern: How to write tests for complex methods/classes. I wrote a class that calculates a binomial distribution. Thus, a method of this class takes n, k, and p as input, and calculates the resp. probability. (In fact it does a bi...