Right my junit tests look like a long story:
I create 4 users
I delete 1 user
I try to login with the deleted user and make sure it fails
I login with one of the 3 remaining user and verify I can login
I send a message from one user to the other and verify that it appears in the outbox of the sender and in the inbox of the receiver.
I...
Most things I read about Unit Tests is about testing your classes and their behaviour. But how do you test saving data to a database and reading data from a database. In our project saving and reading data is done through services that are used by a Flex Application (using WebORB as a gateway). For instance, a service reads all users tha...
I've overridden my controller's OnActionExecuting method to set some internal state based on the executing filterContext. How do I test this? The method itself is protected so I assume I'll have to go higher up in the call stack.
What code do I need to test this?
I'm using mvc RC 1.
Edit: I'm also using nunit.
Thanks
...
I'm trying to unit test a method that performs a fairly complex operation, but I've been able to break that operation down into a number of steps on mockable interfaces like so:
public class Foo
{
public Foo(IDependency1 dp1, IDependency2 dp2, IDependency3 dp3, IDependency4 dp4)
{
...
}
public IEnumerable<int>...
As applying unit-test to some C code, we run into a problem that some static function can not be called at the test file, without modifying the source code. Is there any simple or reasonable way to overcome this problem?
...
I am working on a lib that I want to release in open source. I have started writing the tests for the code, and I was wondering how I am suppose to test a property in a .Net object. Lets say I have the following:
public class Person{
#region variables
private string _name = String.Empty;
private string _surname = String.Em...
I'm searching for a good ASP.NET Unit Testing tool. Googling gives me some tools, but I would like to get started with a good tool.
Any experience with these tools?
Is there a way to do ASP.NET Unit Tests with the build-in Unit Testing in Visual Studio 2008?
...
For classes that have several setters and getters besides other methods, is it reasonable to save time on writing unit tests for the accessors, taking into account that they will be called while testing the rest of the interface anyway?
...
I'm writing a unit test for my UTF8 manipulation library, and I want my test to segfault if a function goes into a buffer overflow. So I came up with the idea to mmap two pages next to each other in memory, the first with PROT_READ | PROT_WRITE, and the second with PROT_NONE. That way, if any overflow occurs, a segfault is guaranteed. ...
The actionscript I want to write looks like this:
public function API(requestClass:Type=URLLoader) {
var req:URLLoader = new requestClass(new URLRequest("some url"));
req.load(url);
//etc
}
so that I can test the API class by passing in a mocked subclass of URLLoader. This doesn't appear to be possible in Actionscript's type sys...
Does NUnit let me invoke a method after every test method?
e.g.
class SomeClass
{
[SomeNUnitAttribute]
public void CalledAfterEveryTest()
{
}
}
I'm aware of [SetUp] and [TearDown], but that only works for the tests in the current class. I want something like [TearDown], except it runs after every unit test, whether its in...
I have an existing VS 2005 Std .NET Compact Framework application that I want to do some major refactorings on. Currently there is no unit testing in place, but I want to add this before messing with the code. I have no practical experience with unit testing, even though I know the theory (just never got around actually implementing it; ...
I want to be better at using NUnit for testing the applications I write, but I often find that the unit tests I write have a direct link to the environment or underlying database on the development machine instead.
Let me make an example.
I'm writing a class which has the single responsibility of retriving a string, which has been stor...
I'm starting a new project and decided that I should give this unit testing thing that everybody keeps talking about a try.
The project is a set of C libraries (so no UI or user interaction testing is necessary) and aimed at being cross platform, with Linux, FreeBSD and Windows being my first priority and OS X planned once the first r...
I've heard many different opinions as to what makes one better than another. But can anyone provide a technical explanation as to why I should choose one unit testing framework over another. For example, I use Visual Studio Team System. Why would I choose an Open Source testing framework (NUnit, xUnit, MbUnit, etc) over Visual Studio's b...
While unit-testing seems effective for larger projects where the APIs need to be industrial strength (for example development of the .Net framework APIs, etc.), it seems possibly like overkill on smaller projects.
When is the automated TDD approach the best way, and when might it be better to just use manual testing techniques, log th...
Some say that a debugger is the mother of all evil. What do you think of this approach?
I have a friend at work, a colleague, who's completely against using a debugger whatsoever.
I asked him: So, you just write code without bugs? Is that it?
He answers: Of course not. Everyone makes mistakes, the difference is how you deal with them ...
I'm trying to write up a custom WebFormView to help with skinning a website I'm working on. The code is loosely based on how it's done in Oxite. The problem I'm having right now though is I'm not sure how I would unit test the Render method since it has a call to the BuildManager.
There are no unit tests for this code in the Oxite proje...
I'm working on a unit test which executes some business logic that will eventually result in a refresh (so execute the same query again) of the data.
Using Dependency Injection (with Castle-Windsor) the unit tests use stub objects, so a static list of entities is returned from the method that gets the data.
So how can I test whether th...
Is there a way to test compile-time errors, but without actually generating the error? For example, if I create a class which is non-copyable, I'd like to test the fact that trying to copy it will generate a compiler error, but I'd still like to execute the other runtime tests.
struct Foo {
int value_;
Foo(int value) : value_(va...