1. Remote deployment
This type of deployment involves deploying the
testing application and the supporting files to the remote machines,
which are used for testing or running the test application. This
deployment is not a direct or automatic deployment as we do with the
local deployment. The first deployment happens in the centralized system
called controller, which then distributes and deploys the application or files to the agent computers. The agents are the actual remote computers on which the application has to be deployed.
For conducting tests such as simulated tests, Visual Studio
requires multiple computers at different locations. This happens in the
case of concurrent user tests or load tests while running the test
simultaneously on multiple computers at different locations or the same
location.
The group of computers consists of a controller and
other agents. The controller is the central computer that communicates
with the agents. So when the remote deployment happens, it first copies
the files to the local deployment folder which is the Out
folder as mentioned in the previous section. Then it is deployed to the
local folder in the controller computer, which then distributes the
files to the agents. The agents are the real computers which conduct the
tests.
The above screenshot shows the test run configuration. For the remote option, we have to provide the Controller and the Agents information for the deployment.
2. Deploy additional files
The configuration settings contain the list of
additional items to be deployed as part of test deployment. Open the
test configuration file, which opens in a configuration editor tool
which is the inbuilt tool in Visual Studio used for easy editing of the
configuration information. In the screenshot below, the Deployment section shown in the configuration editor tool specifies the additional files or folder to be deployed. You can use the Add File or Add Directory option to select the deployment items.
The
other way of achieving the same is to edit the configuration XML file
directly without using the tool. The XML file text below shows a sample
test configuration file with a couple of additional deployment items,
test timeouts, user defined naming scheme, and a setup script.
If we need more files to be added as part of deployment, we can update the Deployment
section directly in the XML file and then add the files. Given here is
the updated deployment section, which includes an additional file CustomRules.dll
to be deployed:
We can edit any section of the XML file to change the configurations. This is similar to the configurations set using the IDE.
3. Using deploymentItem attribute
This attribute can be specified as part of the
unit test methods to deploy additional items for a single test. To
specify the attribute, open the unit test code and open the TestMethod
. Add the DeploymentItem
attribute to the method. Specify the file or folder as a parameter to
the attribute. For example, the following code deploys the test.dll
file as part of the test deployment.
This parameter can specify the file or folder
with an absolute path or a relative path. Relative paths are relative to
the path specified in the test configuration file.
4. Deploy items for individual test
The items specified in the test configuration
setting are the default additional deployment items for the test
project. Each test has its own properties, which includes the list of
additional deployment items. These are specific to this test and not for
the entire test project. To specify the items for a test, open the Test List Editor or the Test View window and select the test. Open the test Properties
window and open the string collection editor for the deployment items
and specify the list of deployment items. For example, the following
screenshot shows the properties specified for a test with two additional
deployment items, Test.dll and Classlibrary2.dll.
The deployment item is a collection property, which contains the list of all the deployment items specified for the test.