Console App to start a CodedUI test

杀马特。学长 韩版系。学妹 提交于 2019-12-12 01:39:22

问题


I have a coded ui test that I want to start by using batch, its a .dll file.

The reason I'm calling it from a batch file is that the server has to be restarted before this test can be carried out.

Is it just a simple call test.dll or do I have to do other stuff?

Update Code Found

Playback.Initialize();
TestProject.CodedUITest1 coded = new TestProject.CodedUITest1();
coded.CodedUITestMethod1();
Playback.Cleanup();

Take from Here, Its missing two reference addings from the private assemblies:

  1. Microsoft.VisualStudio.TestTools.UITest.Extension.Uia.dll
  2. Microsoft.VisualStudio.TestTools.UITest.Extension.IE.dll

Hope this helps other people looking to do this


回答1:


You can't run a Dll file like you can an exe. A Dll contains code intended to be used by a program, it means one source of code can be used by many programs, which saves duplicating the code.

Usually the Dll will have documented functions you can call via a program, unless you built it yourself in which case you would know :)

Try and find the program that uses the Dll and call that, or find the docs for it and run the function from rundll32 as @PA. suggested.




回答2:


DLLs are dynamic libraries that need to be linked and called from an application program. Every DLL has its own exported interface, or collection of entry points to be called from the external executable, or, may be, from another DLL.

Windows provides a set of calls to help caller programs to load, detect entry points, and unload DLLs. Beyond this limited common functionality, there are endless combinations of ways of using a DLL, in the calling conventions, in the ways of passing parameters, in the types of the parameters, in the ways of returning data, in the ways of synchronizing, notifying events, interrupting, multithreading, in almost every aspect of programming models.

Having said so, it is possible that your DLL is expected to be called from some specific application program, and thus is possibly following and strict and well defined API. One such type of DLLs are Windows System DLLs that are intended to be run with rundll executable program. rundll32.exe is the Windows system executable that launches and invokes functions that are packed and shipped in .dll files, from a DLL that is explicitely programmed to be called this way.

to invoke your TestFunction inside your TEST.DLL, passing 1234 as a parameter, you'd use

RUNDLL32  TEST.DLL, TestFunction 1234

Rundll will perform for you the following tasks

  • Load TEST.DLL via LoadLibrary().
  • Address the TestFunction function via GetProcAddress().
  • Call TestFunction function, passing the rest of the command line
  • Unload the DLL and exit.


来源:https://stackoverflow.com/questions/11469323/console-app-to-start-a-codedui-test

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