Windows应用程序如何调用单元测试项目? [英] how to call a unit test project by a windows application?
问题描述
我对Selenium和C Sharp还是陌生的,我设法以某种方式编写了对应用程序进行单元测试的代码,并使用所有7个测试用例输出创建了一个范围报告一切都按预期运行问题是我不想要的每次登录Visual Studio并运行所选的测试用例我有什么办法可以创建Windows应用程序并通过单击按钮使测试用例运行
I am new to selenium and C sharp i somehow managed to write a code that does the unit testing of my application and creates a Extent Report with all my 7 test cases output Everything is working as expected The issue is i do not want every time to log into visual studio and run the selected test case Is there any way i can create a Windows application and make the test cases run with a click of a button
我总共有7个测试用例,并且在运行时可以完美运行,我将它们全部选中并运行所选的测试,但是我不需要每次都去那里,而是想从某些Windows应用程序中运行它.
I have a total of 7 test cases and runs perfectly when running i select them all and run the selected tests, but i need not want to go there everytime , instead want to run it from some windows application.
推荐答案
如果您的单元测试项目中有测试,则可以创建Windows控制台应用程序,并将测试项目添加为对它的依赖项.
If you have your tests in unit tests project, you can create a windows console app and add your test project as dependency to it.
然后,您可以在main函数中创建测试类对象并调用测试方法.
Then you can create your test class objects in main function and call test methods.
using Test.Project.Namespace;
static void Main(string[] args)
{
TestClass testclass = new TestClass();
testclass.TestMethod1();
testclass.TestMethod2();
etc...
}
可以通过许多方式进行改进,但是您明白了.
It can be improved in many ways but you got the idea.
这篇关于Windows应用程序如何调用单元测试项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!