Setting Up Automated Build-Deploy-Test Workflows with TFS 2012

In this Post I will clarify how can you use a build-deploy-test workflow on Visual Studio 2012 to deploy and test your application when you run a build. This lets you schedule and run the build, deployment, and testing of your application with one build process. Build-deploy-test workflows work with Lab Management to deploy your applications to a lab environment and run tests on them as part of the build process.

If your lab environment is an SCVMM environment, you can also use workflows to create and restore snapshots that automatically create a clean environment before you run tests, and to save the state of your environment when a test fails. This ensures that each test isn’t influenced by changes to the lab environment from previous test runs. In addition, it ensures that testers can accurately reproduce that state of a lab environment when they reproduce bugs.

You can use a build-deploy-test workflow in the following scenarios:

  • Build, Deploy, and Test − Build your application, then deploy it and run automated tests on it in a lab environment. This workflow enables you to run a series of tests from a test plan, on a deployed application, as part of your build process. This scenario is common when running build verification tests.
  • Deploy and Test − This scenario is similar to the “build, deploy, and test” scenario, except a new build isn’t created during the workflow. Instead, the workflow uses an existing build from a drop folder.
  • Deploy Only – Deploy an existing build from a drop folder to a lab environment without running automated tests during the workflow. Once a build has passed your build verification tests, and is ready to be sent to a test team, you might want to send that specific build to the test team so they can run additional tests that aren’t part of your workflow. This scenario is common when running manual tests.
  • Build and Deploy – This scenario is similar to the “deploy only” scenario, except a new build is created during the workflow.

A build-deploy-test workflow is a Windows Workflow file that defines how a build definition will run a build, deploy an application, and run tests. A build-deploy-test workflow is created in a build definition by choosing a build process template called the lab default template (LabDefaultTemplate.11.xaml), and configuring the settings. You can also create a customized build process template for your workflow depending on your requirements. You configure your build definition after you set up your build machine, test machines, and lab environments.

The deployment settings in a build-deploy-test workflow define how an application is deployed by specifying the deployment scripts to run on specific machines in your lab environment. You can specify a lab management role to run each deployment script on, or you can specify a specific machine in your lab environment. Creating deployment scripts is a major part of setting up build-deploy-test workflows. Deployment scripts copy files from your build to your lab environment, and then run your installation packages.

The following diagram describes how a build is deployed by a build-deploy-test workflow:

Dataflow for deployment scripts.

The following steps are displayed in the diagram above.

  1. The build-deploy-test workflow starts a build, and then gets the deployment scripts.
  2. The build definition copies the build files to the drop location.
  3. The workflow runs each deployment script in the working directory of the specific machine or machine role that the script is assigned to.
  4. Each deployment script retrieves build files from the drop location.
  5. Each deployment script copies or installs the specified build files onto machines in the lab environment.

You must complete these steps before you set up a build-deploy-test workflow.

  1. Configure Team Foundation Build ServiceSet up a build configuration for your team project collection using the Administration Console for your Team Foundation Server. When you set up your build configuration, you will select build controllers and build agents to use when building and deploying your application. For information on setting up your build configuration, see How to Configure a Build Machine.
  2. Set up a test controllerInstall a test controller and register it with your team project collection.
  3. Set up a lab environmentSet up a lab environment. Your lab environment can be an SCVMM environment or a standard environment. When you set up your lab environment, test agents will be installed on each machine in the environment. For information about creating a lab environment.
  4. Additional steps to run automated tests from a test plan in a lab environmentBefore running automated tests from a test plan, you must first associate your automated tests with test cases from that test plan. When you run automated tests from a test plan, you must use a lab environment. To create a test plan and associate your automated test with it, you must carry out the following tasks.
    1. Create a test plan and test suite.
    2. Associate your automated tests with test cases from your test suite.

Now Enjoy  deploy and test your applications with a running build!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s