how to call a unit test project by a windows application?

一笑奈何 提交于 2019-12-11 17:45:53

问题


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

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.


回答1:


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.

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.




回答2:


I would suggest that you create a Windows batch file that triggers your automation. Since you are using NUnit, this should be pretty straightforward. You point it at your automation dlls, you can specify test categories, etc. Take a look at the docs and other resources on the web.



来源:https://stackoverflow.com/questions/58015236/how-to-call-a-unit-test-project-by-a-windows-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!