Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I need to start using unit tests in my code . The problem is that i never written unit tests . Can you please recommend me some good sites and book how to write correctly unit tests and to use nunit application .
Thanks a lot for help.
I would recommend you get The Art of Unit Testing by Roy Osherove
I think Pragmatic Unit Testing is a good complementary book for Osherove's Art of Unit Testing. Pragmatic unit testing deals with flushing out errors and different types of targeted testing, whereas Roy's book is a higher level and more general book that deals with a wider range of concepts.
As a beginner, I found the Pragmatic book an excellent starting point.
Here are some other quality resources:
Misko's guide to writing testable code. One of the main battles when writing tests is ... how to structure code to make it testable. Misko's guides are invaluable.
Roy Osherove's cranky test review videos. The second battle we face is writing good, clear, maintainable tests. It's really easy to write bad/brittle/unmaintainable tests, so it is important to be aware of common mistakes. These videos can be a bit cranky at times, but they're full of good tips.
It may be a little dated, but the one I started with was Test Driven Development In Microsoft.NET.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm looking for a framework to help automate my integration tests. C# / VS2013.
The requirements are basically exactly the same as for a unit testing framework, except that I need to be able to specify the order that tests are executed in, because the tests are affecting a database (which is wiped at the start of the test and is always in a deterministic state throughout the tests) and gradually building up a very large number of products and other items which all interact with each other.
I'm currently using MbUnit / Gallio, but it seems like they've ceased development and can't launch VS2013 to debug. Is there anything else out there?
And I'm saddened by having to add this, but what I DO NOT NEED is people telling me how unit tests ought to be independent and mock the database layer. I've got unit tests, thanks. They don't give me enough coverage of some of the interactions I need to test, which is why I am automating integration testing in addition.
Visual Studio's unit test framework (mstest) has "Ordered Test" that will allow you to specify test execution order.
You can run tests in an order from command line through /testcontainer:test.dll /test:test1 /test:test2 /test:test3. Moreover the tests will run on alphabetical order.
maybe this links help ordered execution of tests in visual studio
There is also a design pattern described by martin fowler Gateway
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
When I was on my industrial year as part of my degree, I ran our FV tests using JUnit inside of Ant (scheduled build system).
I am wondering:
Is this the "norm"?
Are there any other ways people run there tests?
Please note this is regarding how people in large teams within organisations (test engineers) run there tests.
Edit: I used eclipse with IBM RTC.
Thanks.
You should look at Continuous Integration (CI). With tools like Jenkins, Hudson, TeamCity, you check in your code, then at a build server, your code is tested and reported for coverage and test results etc.
Also before any deployment your tests should run and pass with some criteria you define.
You can have unit tests, acceptance tests, end to end test, all these can be automated at a build server.
For large/enterprise applications, you should definitely use CI.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Hi friends,
I want to use NBehave with Visual studio unit testing frame work. I have tried to dig into many links but most of them explains NBehave with MBUnit.
Can any one help me to find any resources to use NBehave with VS Test?
I used to really like nbehave and I think it is a great product but it has one simple flaw. It has a custom test runner and therefore nothing else integrates with it as easily as the more common used frameworks.
As #Fresh points out in the comments, SpecFlow is the far more commonly used framework for plain text specification testing on DotNet. I've chosen to use it on my most recent projects because you just use the nUnit or mstest test runner of your choice, which means instant integration with tools such as ReSharper, TeamCity, dotcover, nDepend, and of course the integrated test runner in Vs2012 and later.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I decided to start studying code from other developers to improve my coding skills.
I'm looking for a open-source software that uses MVC pattern, and also most design patterns possible.
Could you recommend some open-source software written in C# or VB.NET that uses as many design patters as possible or some code that worth studying?
I would recommend some projects like NServiceBus, which make extensive use of polymorphism (not to mention the NServiceBus API is one of the best APIs I've had the pleasure of using). Also consider something like StructureMap, which uses a model-based configuration API (I actually use Ninject as my IoC of choice, and it could prove to have some interesting code as well). It's hard for me to point out whether or not these projects use specific design patterns, and how many it may use, but I do know that they use some modern APIs and modern approaches to object oriented design.
I would say, though, that your best bet is going to be to find an open source project that you find interesting, or that you use regularly, and crack it open and see what makes it tick. If you are familiar with the details of using the code (whatever it may be), then you will probably gain more insight be looking at the code because you know what it is doing.
I always recommend .NET Domain-Driven Design with C#: Problem-Design-Solution sample code - SmartCA project. It is extremely elegantly laid out and I find myself going back to it whenever I have doubts about my architecture.
You should also download and check out ASP .NET MVC source code. It's got good examples of unit testing and mocking (which is something you will find yourself wanting to use).
I'd recommend checking out the Northwind Starter Kit (http://nsk.codeplex.com/) - it covers off on many design patterns and their application in the .Net framework, including SOA and MVC/MVP/PM concepts. It also includes examples of several other free-to-use libraries, such as Microsoft Entity Framework and NHibernate.
I'm personally particularly pleased with the way they show the same backend can be used with both WPF and ASP.Net.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
Is there a good tool to generate unit test cases given say a .NET or Java project, it generates unit test cases that would cover an almost 100% code coverage. The number of test cases could be directly proportional to the cyclomatic complexity of the code (the higher the nesting of loops and conditions the higher the cyclomatic complexity) where the higher the cyclomatic complexity, the greater the set of test cases are generated. I'm not expecting it to be fully functional (say I'm going to build the unit tests and run it after its been generated), but I would say that it can have a template style in the test case where you are to modify the case that suits your intended needs. But it should also have a proper setup and teardown method and is good enough to detect if mock objects for unit testing should be used should there be any dependencies. So, is there such a tool that exists?
For .NET, Microsoft has Pex which will hopefully go mainstream for .NET 4.0, along with Code Contracts. I highly recommend watching the Channel 9 video.
It strikes me that this sort of thing is very good for very data-driven classes - parsers etc. I can't see that I'd very often start off with it, but a useful tool to have in your armoury nonetheless.
For C# (or .NET in general), PEX might be that tool. It works at the IL level, and attempts to force its way into every branch. It has successfully uncovered a wide range of bugs (in the BCL etc).
Although it seems counter-intuituve, you may also be interested in random test generation frameworks. Research has proven that it can be just as effective in finding bugs than systematic approaches based on coverage, as you suggest.
Check out Randoop both for .NET and Java. It works by generating a more or less random sequence of method calls, and checks contracts, crashes etc. It is fully automatic.
Also you may want to check out some other random testing tools based on QuickCheck, e.g. for Java, Scala, F#. that are more similar to Pex, i.e. you give a specification, or parametrized unit test, and the tool checks it for a number of generated input arguments.
I've found that this "parametrized" way of writing unit tests is actually a lot more natural in at least 60% of the cases, and finds lots more bugs.
For Java, you can check EvoSuite, which is open source and currently active (disclaimer, I am one of its contributors). Also see related question for a list of more tools.
For Java, try JUnit-Tools. It has own eclipse plugin along with good documentation.