unit-testing

Unit testing WCF

Hi, I am new to WCF. I wrote a service and consumed the service in client application. Now I want to write unit tests for both the server and client. What are the guidelines I should fallow to write unit tests for WCF. I googled and came across different ways to Unit test WCF. But really not sure which one is better. I am using vs20...

How to write a unit-test for the outcome of Dispose()

Is there a good way of testing the result of the IDisposable.Dispose()-method? Thanks for all your answers. ...

A few questions about unit tests

Two questions about unit tests. I've been writing unit tests for a while, however they're usually to test classes I already had written. Recently I read an article (mind you an old article) that says you should write unit tests before you begin writing your code. Does anyone actually follow this methodology? It seems like a good idea...

What differences are there between the frameworks that exist for unit testing vb6?

For my sins in a previous life I am currently faced with having to modify some legacy VB6 COM+ code. The client absolutely does not want us to upgrade this code to .NET so that is not an option in this case. I am uncomfortable touching this code without adding unit tests to it, but while I am experienced in using tools in the XUnit fa...

Set a test timeout duration with PHPUnit

I have some test cases that can go into an infinite loop upon failure. Is there a built-in way to set a test timeout duration with PHPUnit? If not, what would be the most unobtrusive way of adding this feature to a test case? ...

NUnit: abort test if it takes too long

Is there a nice and simple way to get NUnit to kill a test that takes more than a specified amount of time? Ideally it would not only kill the app domain in which the test was running, but also any child processes the test started. ...

Testing Code With Threads in .NET

I need to test my vigorously tested code works when called by many threads So I am calling the code in a loop in a TestMethod using TreadPool.QueueUserWorkItem however there does not seem to be anyway of holding the current thread while all the threads kicked off are still running. i.e. pretend code.... using Microsoft.VisualStudio.T...

Unit testing specific values

Consider the following code (from a requirement that says that 3 is special for some reason): bool IsSpecial(int value) if (value == 3) return true else return false I would unit test this with a couple of functions - one called TEST(3IsSpecial) that asserts that when passed 3 the function returns true and another th...

Why doesn't the following mocking with Ninject.Moq work?

I'm trying to run the following code with Ninject.Moq: [TestMethod] public void TestMethod1() { var kernel = new MockingKernel(); var engine = kernel.Get<ABC>(); //as I don't need to actually use the interfaces, I don't want //to even have to bother about them. Assert.AreEqual<string>("abc", engine.ToString()); } A...

Boost.Test application debugging

When debugging a C++ Boost.Test application inside VS2010 (VS2008), how to make the debugger stop at Boost.Test assertion failure points? ...

Writing unittests for a function that returns a hierarchy of objects

I have a function that performs a hierarchical clustering on a list of input vectors. The return value is the root element of an object hierarchy, where each object represents a cluster. I want to test the following things: Does each cluster contain the correct elements (and maybe other properties as well)? Does each cluster point to t...

What's the best way to unit test code that generates images?

What is the best way to unit test code that generates images? Say, for example, a class that generates a plot or a chart? ...

Formulating both general and specific stub-methods?

Hello, in order to test another class, I want to create a stub for an interface IFoo: public interface IFoo { int DoSomething(int value); } The stub is created in the SetUp (or TestInitialize)-method for the test fixture and stored in a property as almost all test methods need an IFoo: this.Foo = MockRepository.GenerateStub<IFoo...

How can I fake HttpContext for unit tests?

Hello, I need to fake HttpContext.Current.Application table to access it from my unit tests. I need to store my data somewhere. I thought that I can just pass instance of NameValueCollectionBase but as I descover this base type has no indexer so it's too complicated to use. So what about faking this part of HttpContext? Is it possib...

Unit testing implies testing controllers/views too?

I want to understand exactly what unit test means. From what I have understood so far it implies testing a model and all its public methods. Is that correct? And what about controllers? Does unit test means testing the controllers/views too? Could someone enlighten me on this. ...

How do I run django test case?

I am using twisted to pass in a variable into my django environment so I have to run the twisted server. Hence when I am testing my django app I really need to run the twisted code it runs something like this: def wsgi_resource(): pool = threadpool.ThreadPool() pool.start() # Allow Ctrl-C to get you out cleanly: reactor...

assert_equal says <0.15> expected but was <0.15>, but only if the method computes 0.15 in a certain way

So for this model method: def tax_rate tax_rate = 0.0 tax_rate += STATE_TAX if state_taxable? #STATE_TAX = 0.1 tax_rate += IMPORT_TAX if imported? #IMPORT_TAX = 0.05 tax_rate end This test fails: @item.update_attributes({:state_taxable => true, :imported => true, :price ...

A good UI Unit Testing solution suitable for ASP.NET development (browser UI compatible)?

Hi, does anyone know of a good automated UI Unit Testing solution suitable for ASP.NET development (Browser UI compatible)? Would be interested in learning it if so. NUnit integration / compatibility would be a bonus. ...

Unit testing rules.

Hi, My question may appear really stupid for some of you but i have to ask.. Sorry.. I don't really understand principles of unit testing.. How can you test classes of your business classes or Data access layer without modify your database? I explain, i have a functionality who update a field in a database.. Nothing so amazing.. The B...

Practical way to do unit testing with code that changes the environment

Hello, I keep reading a lot of opinions in favor of Unit Testing, which is a procedure I have not been following so far and have a few questions. As I understand it, the basics of Unit Testing is to run some procedures in your code, and compare the returned value against the expected value, and see if it matches to determine whether a ...