Easy is a tool that makes test-driven development easier. At the beginning of doing TDD, I found it awkward that I needed to write more code for tests than for actual production code. It was also inconvenient to spend more time writing test code than production code. To address this, I created a couple of code generation scripts that improved performance, but they were not user-friendly. That's how easyTdd was born. The tool is still in its early stages and is being developed iteratively. It works with MsTest, NUnit, Xunit test frameworks and can generate tests, mocks, builders, and test cases. ConfigurationAfter installing the plugin, once the solution is opened for the first time, the ".easyTdd" folder is generated in the solution folder. It contains files for templates and a "settings.json" file for configuration. Scriban is used for template parsing. ReSharperEasyTdd features are implemented using the Visual Studio Quick Action menu. ReSharper might override this menu and hide it. To enable it, go to ReSharper's options and uncheck "Hide Visual Studio Quick Action icons in the left editor margin": Main featuresGenerating mock classIt generates a class that inherits from the Moq.Mock class and has a fluent, chainable structure, which is easier to use in easyTdd scenarios. You can customize it by modifying the "mock.tpl" file in the ".easyTdd" folder. To generate a mock, right-click on an interface or abstract class and select "Generate Mock": A mock is generated, and the file is opened: If mocks have already been generated for interfaces or abstract classes, you will see options for "Open [FooMock.cs]" and "Regenerate [FooMock.cs]": Generating buildersThe builder pattern is used for concrete class usage in tests. You can generate a builder by right-clicking on a concrete class and selecting "Generate Builder": A builder is generated, and the file is opened: For classes that already have a builder generated, you will see options for "Open [FooBuilder.cs]" and "Regenerate [FooBuilder.cs]": You can customize it by modifying the "builder.tpl" file in the ".easyTdd" folder. Generating testsThe "Generate Test" action creates a test file, generates dependencies in the form of test doubles, creates the subject under test, and generates methods for testing invalid input cases and for dependency calls: The output is opened: Feel free to remove anything that is not needed; it is easier to remove than to type everything by hand. For classes that already have a test generated, you will see options for "Open [FooTest.cs]" and "Regenerate [FooTest.cs]": You can customize it by modifying the "[test framework].test.tpl" file in the ".easyTdd" folder. Generating test casesThe "Generate Test Cases" action generates a test case method for parameterized tests: An attribute for the test is added, and the source method is generated: You can customize it by modifying the "[test framework].test-cases.attribute.tpl" and "[test framework].test-cases.source-method" files in the ".easyTdd" folder. Generating test cases in an external file"Generated Test Cases in External File" generates a test case class for parameterized tests:
You can customize it by modifying the "[test framework].test-cases-external.attribute.tpl" and "[test framework].test-cases-external.source-class.tpl" files in the ".easyTdd" folder. |