Auto-generation of .NET unit tests

后端 未结 12 1623
故里飘歌
故里飘歌 2020-12-14 14:59

Is there such a thing as unit test generation? If so...

...does it work well?

...What are the auto generation solutions that are available for .NET?

相关标签:
12条回答
  • 2020-12-14 15:24

    I agree with Jon. Certain types of testing, like automated fuzz testing, definitely benefit from automated generation. While you can use the facilities of a unit testing framework to accomplish this, this doesn't accomplish the goals associated with good unit test coverage.

    0 讨论(0)
  • 2020-12-14 15:26

    Updated for 2017:

    Unit Test Boilerplate Generator works for VS 2015-2017 and is being maintained. Seems to work as advertised.

    0 讨论(0)
  • 2020-12-14 15:28

    Take a look at Pex. Its a Microsoft Research project. From the website:

    Pex generates Unit Tests from hand-written Parameterized Unit Tests through Automated Exploratory Testing based on Dynamic Symbolic Execution.

    UPDATE for 2019:

    As mentioned in the comments, Pex is now called IntelliTest and is a feature of Visual Studio Enterprise Edition. It supports emitting tests in MSTest, MSTest V2, NUnit, and xUnit format and it is extensible so you can use it with other unit test frameworks.

    But be aware of the following caveats:

    • Supports only C# code that targets the .NET Framework.
    • Does not support x64 configurations.
    • Available in Visual Studio Enterprise Edition only
    0 讨论(0)
  • 2020-12-14 15:28

    I've used tools to generate test cases. I think it works well for higher-level, end-user oriented testing. Stuff that's part of User Acceptance Testing, more so than pure unit testing.

    I use the unit test tools for this acceptance testing. It works well.

    See Tooling to Build Test Cases.

    0 讨论(0)
  • 2020-12-14 15:28

    Selenium generates unit tests from user commands on a web page, pretty nifty.

    0 讨论(0)
  • 2020-12-14 15:29

    Parasoft .TEST has a functionality of tests generation. It uses NUnit framework for tests description and assertions evaluation.

    It is possible to prepare a regression tests suite by automated generating scenarios (constructing inputs and calling tested method) and creating assertions which are based on the current code base behavior. Later, after code base under tests evolves, assertions indicates regressions or can be easily recorded again.

    0 讨论(0)
提交回复
热议问题