Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automated Unit Testing Gen Tools for .NET

Tags:

Looking to get your take on an automated testing tool (voting should bring good ones to the top)

Ideal tool would:

  • Eliminate the need to present a set of values to a method.
  • employ techniques such as Interactive Exploratory Testing where the code is examined to determine what values are required to exercise all code paths. i.e. the unit tests for a method is determined by the complexity of the code

For example, if a method checks that an integer argument is 123, at least 2 unit tests are generated: one where that argument is 123 and one where it is not.

For Java my understanding is these are some options but not .NET

  • TestGen4J
  • AgitarOne

Have heard of Pex - For .NET from Microsoft Research but this has a non-commercial license

Thanks

like image 816
BrianP Avatar asked Sep 05 '08 18:09

BrianP


People also ask

Which tools are used for unit testing in .Net solutions?

xUnit is a free, open-source, community-focused unit testing tool for . NET. The original inventor of NUnit v2 wrote xUnit.net. xUnit.net is the latest technology for unit testing .

What is tool used for automated unit test?

Answer: Selenium is a UI Functional testing tool and is used for web-based applications. It automates User interface testing through different language bindings and can run tests on multiple browsers and OS combinations.

How do you automatically generate unit tests?

To generate unit tests, your types must be public. Open your solution in Visual Studio and then open the class file that has methods you want to test. Right-click on a method and choose Run IntelliTest to generate unit tests for the code in your method. IntelliTest runs your code many times with different inputs.

What is the best unit testing framework for .NET core?

While MSTest comes inbuilt with Visual Studio, NUnit makes testing faster and more extensible. Among the top 3, xUnit is considered the best unit testing framework for C# simply because it has fewer attributes and makes the code clean and easy to maintain, it is also extensible just like NUnit.


2 Answers

Pex enables parameterized unit testing and uses dynamic symbolic execution (some kind of automated exploratory testing) to generate inputs. Pex can understand the semantics of MSIL, i.e. of any managed method call. In the '123' example, Pex would find both tests.

It lets developers write parameterized unit tests - so it totally fits in a test-first development style.

For commercial software, Pex requires an MSDN license. More info at http://research.microsoft.com/pex

a pex developer :)

like image 51
Peli Avatar answered Sep 30 '22 18:09

Peli


I've tried some of these tools in other languages and IMHO they are almost a complete waste of time. Reason? They can't guess at the semantics of a method call in any meaningful way. There's a very good article about this here -- well worth a read.

like image 25
Phil Bennett Avatar answered Sep 30 '22 18:09

Phil Bennett