Skip to content

Repository files navigation

Testura Logo

Testura.Code.UnitTestGenerator is a simple framework/tool to inspect assemblies and generate unit tests from exported types. It's created as a simple example on how you can use Testura.Code

Client

https://github.com/Testura/Testura.Code.UnitTestGenerator/releases

Basic info

Supported test frameworks

  • MsTest
  • NUnit

Supported mock frameworks

  • Moq

Will generate

  • A unit test file for all types that are exported and isn't static or abstract
  • A setUp that initialize the type under test (TuT) by looking at it's first constructor.
  • All required parameters will either be mocked, initialized or set to some default value.
  • Will generate fields for TuT and required parameters
  • All files created will follw your assembly namespace/directory strcture.

Example usage from api

varunitTestGenerator=newUnitTestGenerator();unitTestGenerator.GenerateUnitTests(DllPath,TestFrameworks.NUnit,MockFrameworks.Moq,OutputDirectory);

GUI

Gui

Example of generation

Type under test

namespaceTestura.Android.Device.Services.Default{publicclassUiService{publicUiService(IScreenDumperscreenDumper,SomeClasssomeClass,stringmyString,intnumber){}}}

Generated unit test

namespaceTestura.Android.Tests.Device.Services.Default{[TestFixture]publicclassUiServiceTest{privateMock<IScreenDumper>screenDumperMock;privateSomeClasssomeClass;privateUIServiceuiService;[SetUp]publicSetUp(){screenDumperMock=newMock<IScreenDumper>();uiService=newUiService(screenDumperMock.Object,someClass,string.Empty,0)}}}

About

A simple framework/software that inspect your assembly and generate unit tests for you

Resources

Stars

19 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages