NUnit test generator - testing

What good (free) generator can be recommended for NUnit tests?

You're going to have to say exactly what you want the generator to do. Personally I've always found automated generators to be more hassle than they're worth - my fingers work just as well :)
On the other hand, you might want to look at Pex which works in conjunction with Code Contracts to explore your code and generate tests in an intelligent way. Pex is able to generate tests in different flavours, including NUnit.

Test generators are good at giving you high code coverage. Unfortunately high code coverage doesn't always mean good tests have been generated. I tend to write them out by hand myself.

Just downloaded and installed Novel's NUnitGenAddIn. It's kind of old-ish (seems to have been last updated in 2006), but once I tweaked the NUnitGenAddIn.AddIn file (change the Assembly path and update the Visual Studio version number to 9.0), it does exactly what I wanted: right-click generation of reasonable unit-test stubs from within Visual Studio 2008. Dunno if that works for what you want, but definitely free (GNU Lesser GPL).

Dont do it. Tests with value are generated first, by a human (ideally a pair thereof) with their thinking caps on, not their brain in neutral. (That is if you're referring to generating a test per method, or anything else that's not based on some deep insight a la Pex as Jon Skeet said)

If you use resharper you can right-click on a class or method and generate a test class plus one or more test methods (Sorry this was wrong it is part of vs2010)

Related

Where do I put tests in an fsharp project using Monodevelop?

I am doing an assignment (implementing an algorithm), and I wanted to try, this time, implementing tests first. However, I simply do not know where to put them! Do I need to create a new project?
All the tutorials I have found mentioned what to write, but not the general method of proceeding when building a test suite.
I expected Monodevelop to have some kind of predefined structure (like a big "add test suite" button), but I could not find anything for FSharp.
Monodevelop seems to have many tools to deal with tests in a clean and principled way (it does have a big "run tests" button), therefore I thought I would structure my project so that Monodevelop "sees" my tests, so that I could use the tools from the graphical interface. It seems the most common way to write tests is to use NUnit, what if I use something else, like FsCheck?
I have stumbled upon a Github project called FSharpKoans, it seems to suggest that I should create a project called "MySolution.Test" inside a solution, is this the standard way?
What should be the type of the project then, is it a separate console application?
Thanks.
Yes, creating a separate "X.Test" project is the standard way of adding tests in .NET, F# is no exception here.
For testing framework, pick one that Monodevelop supports well if what you're looking for is IDE integration - NUnit sounds like a safe choice. You could conceivably use any framework in F# tests, so I would think what Monodevelop supports should dictate your choice here.
FsCheck is not a testing framework, it's a library for property-based testing that can be used in conjunction with any testing framework. You might want to look into it as it advocates a particularly interesting approach to testing, but it's by no means the only way or the required way of doing testing in F#.

Does anyone know of a tool that will auto-generate Unit Test stubs?

I am writing a winforms application and eventually I would like to write unit test for this application from the DAL, and Biz Objects layers etc.
Does someone know of a FREE tool that can recieve the path to an assembly and then output unit test stubs with matching signatures for the assembly.
Any configurable options like "public interfaces only", "test framework choice", "language choice" would be a plus.
I at least would need this tool to emit vb.net against nunit.
Thanks.
Seth
Last I heard, the recommended method of unit testing was to write them as you develop the functionality in a test first style. Auto-generating unit test stubs, in my mind, would just result in a whole bunch of unimplemented unit tests which add no value and will most likely have very awful generic names that don't describe the behavior being tested.
On the other hand, maybe I'm just misunderstanding your question...
Take a look at Pex from Microsoft Research.
MS Unit test build into VS2008 can create stubs (using Reflection) in your behalf.
I found it very useful in most cases.
There is a tool called Pex that not only makes the stubs, but also fills in tests for you. There's also a video online.
edit: Mark Seemann beat me to it! Hopefully the links are still useful.

Are there BDD/TDD tools for developing in VB.NET?

I am responsible for rewriting an internal tool for my company. I am currently reworking the most time consuming step to run faster which should give me time to re-think the design of the application for a full rewrite as the interstitial version will meet the current needs.
I really want to take this opportunity to implement this code using BDD/TDD but I am new to this method of programming in general and especially within the context of .NET. Are there BDD/TDD tools available for .NET? What resources should I look at?
Thank you very much in advance!
Ashish
As one of the members joked when we discussed BDD at one of our alt.net oresund meetings: "there are more BDD frameworks for .Net, than there are people using them" ;-)
When starting with BDD, or having executable acceptance tests, I recommend to first understand "what's in a story" (i.e. how to define the requirements.
Having nailed a few of those, then you can go find a tool that fits your particular needs in your particular context.
At my current project we chose StoryQ as our BDD tool since we were already using NUnit and TestDriven.Net, and didn't have to add anything but an assembly reference (no separate test runner, etc).
At the aforementioned alt.net meeting, one of the members demonstrated using Cucumber under IronRuby for an app written in C#.
Many people appreciate the way Cucumber turns plain English into requirements, why that might be worth investigating.
Resharper, Nunit, xUnit, MBUnit, are just some of the things that spring to mind.
Resharper because of the nice testrunner and the neat refactorings it can do. (not free)
NUnit because I use that now. (free)
NCover because sometimes you miss a spot. (not free anymore).
Structuremap because IoC/Di is a given. (free)
Rhino mocks because you need to stub and mock. (free)
ASP.Net MVC if you need webdevelopment.
That is just my current stack.
I forgot a few others. But most things that work in C# will now work in VB.Net. And they will work even better in VB.Net 10

Easy acceptance testing with specification

I look for a tool/framework to make automatic acceptance-testing. The interface to create new tests should be so easy, that a non-programmer (customer, boss) will be able to add specifications for which will be tested automatically.
It should be some way to execute the tests from command-line, to include a run of the tests in automatic builds.
I prefer Java and Open-Source, but my question isn't restricted in that way.
What do you can recommend and please explain why your tool/framework is the best in the world.
http://fitnesse.org/ appears to meet all of the qualifications you want. It is one I have used with success.
I think that several of the options are very good and you should test them to see which fits your team :
Cucumber (Ruby)
Fitnesse
Robot framework (Python/Java)
Behave for Java
SpecFlow (.net)
Another framework you may want to look at is Robot Framework. To see how test cases look like, take a look at the Quick Start Guide.
I've found a framework named Concordion that may fulfill my needs.
What you ask for appears to be for a very well-defined system with a very specific sets of inputs and a high degree of automation built-into the system or developed for your system.
Commercial applications such as HP Quick Test Pro isn't non-technical enough and requires an additional framework such as one from Sonnet, which is a step in the right direction, but neither is open source or java-based.
Even with a framework in place, it's quite a bit of work to make this work in an automated way. I'd like you to consider the time needed to develop the framework vs the time to manually run these tests and verify that you are using your time well.
How about Cucumber:
Feature: Acceptance testing framework
Scenario: an example speaks volumes
Given a text example
When it is read
Then the simplicity will be appreciated
You would need a developer to discuss with the boss what each of those lines really means and implement the step definition to drive it:
Given /^a text example$/ do
file.open("example.txt", "w") { |file| file.write "text example" }
end
When /^it is read$/ do
SystemUnderTest.read("example.txt")
end
Then /^the simplicity will be appreciated$/ do
SystemUnderTest.simplicity.should be_appreciated
end

What is a good regression testing framework for software applications?

Am looking for a regression test framework where I can add tests to.. Tests could be any sort of binaries that poke an application..
This really depends on what you're trying to do, but one of the features of the new Test::Harness (disclaimer: I'm the original author and still a core developer) is that if your tests output TAP (the Test Anything Protocol), you can use Test::Harness to run test suites written in multiple languages. As a result, you don't have to worry about getting "locked in" to a particular language because that's all your testing software supports. In one of my talks on the subject, I even give an example of a test suite written in Perl, C, Ruby, and HTML (yes, HTML -- you'd have to see it).
Just thought I would tell you guys what I ended up using..
QMtest ::=> http://mentorembedded.github.io/qmtest/
I found QMTest to full fill my needs. Its extensible framework, allows you to write very flexible test classes. Then, these test classes could be instantiated to large test suites to do regression testing.
QMTest is also very forward thinking, it allows for weak test dependencies and the creation of test resources. After a while of using QMTest, I started writing better quality tests. However, like any other piece of complex software, it requires some time to learn and understand the concepts, the API is documented and the User Manual give a good introduction. With sometime in your hand, I think QMTest is well worth it.
You did not indicate what language you are working in, but the xUnit family is available for a lot of different languages.
/Allan
It also depends heavily what kind of application you're working on. For a commandline app, for example, its probably easy enough to just create a shell script that calls it with a whole bunch of different options and compares its result to a previously known stable version, warning you if any of the output differs so that you can check whether the change is intentional or not.
If you want something more fancy, of course, you'll probably want some sort of dedicated testing framework.
I assume you are regression-testing a web application?
There are some tools in this kb article from Microsoft
And if I remember correctly, certain editions of Visual Studio also offer its own flavor of regression testing tools as well.
But if you just want a unit testing framework, the xUnit family does it pretty well.
Here's JUnit and NUnit.