Get e-book Software Testing with Visual Studio Team System 2008

Free download. Book file PDF easily for everyone and every device. You can download and read online Software Testing with Visual Studio Team System 2008 file PDF Book only if you are registered here. And also you can download or read online all Book PDF file that related with Software Testing with Visual Studio Team System 2008 book. Happy reading Software Testing with Visual Studio Team System 2008 Bookeveryone. Download file Free Book PDF Software Testing with Visual Studio Team System 2008 at Complete PDF Library. This Book have some digital formats such us :paperbook, ebook, kindle, epub, fb2 and another formats. Here is The CompletePDF Book Library. It's free to register here to get Book file PDF Software Testing with Visual Studio Team System 2008 Pocket Guide.

Code reviews and code walkthroughs are also conducted. Once the coding is completed, then comes the Validation phase, where different phases or forms of testing are performed. This is performed by the developer to check whether the developed code meets the stated requirements. If there are any defects, the developer logs them against the code and fixes the code. The code is retested and then moved to the testers after confirming the code without any defects for the piece of functionality.

This phase identifies a lot of defects and also reduces the cost and time involved in testing the application and fixing the code. This testing is completed as a part of unit or functional testing, and sometimes becomes its own standalone test phase. On a larger level, integration testing can involve putting together groups of modules and functions with the goal of completing and verifying that the system meets the system requirements.

Defects found are logged and later fixed by the developers. The low-level components are tested later. In this case, the low-level functionalities are tested and integrated first and then the high-level functionalities are tested.

Introduction to Microsoft Visual Studio Team System 2008 Test Edition

The disadvantage in this approach is that the high-level or the most complex functionalities are tested later. The inputs for functions are integrated in the bottom-up approach and then the outputs for the functions are integrated in the top-down approach. The system test design is derived from the system design documents and is used in this phase. Sometimes, system testing is automated using testing tools.

Once all the modules are integrated, several errors may arise. Testing done at this stage is called system testing. Defects found in this testing are logged and fixed by the developers. The main objective of this type of testing is to determine if bug fixes have been successful and have not created any new problems. Also, this type of testing is done to ensure that no degradation of baseline functionality has occurred and to check if any new functionality was introduced in the software.

We will look at these testing tools and the supporting tools for managing the testing in Visual Studio in detail later. Unit test As soon as the developer finishes the code, the developer wants to know if it is producing the expected result before getting into any more detailed testing or handing over the component to the tester. The type of testing performed by the developers to test their own code is called Unit testing. Visual Studio has great support for Unit testing. The main goal of the unit testing is to isolate each piece of the code or individual functionality and test if the method is returning the expected result for different set of parameter values.

It is extremely important to run unit tests to catch the defects in the early stage. The methods generated by the automated unit testing tool call the methods in the classes from the source code and test the output of each of the methods by comparing them with the expected values. The unit test tool produces a separate set of test code for the source. Using the test code we can pass the parameter values to the method and test the value returned by the method, and then compare them with the expected result.

The generated unit testing code will contain several attributes to identify the Test Class, Test Method, and Test Project. These attributes are assigned when the unit test code gets generated from the original source code. Then using this code, the developer has to change the values and assert methods to compare the expected result from these methods. The Unit test class is similar to the other classes in any other project. The good thing here is that we can create new test classes by inheriting the base test class. The base test class will contain the common or reusable testing methods.

This is the new Unit testing feature which helps us reduce the code and reuse the existing test classes. Whenever any code change occurs, it is easy to figure out the fault with the help of Unit tests, rerun those tests, and check whether the code is giving the intended output. This is to verify the code change the developer has made and to confirm that it is not affecting the other parts of the application. All the methods and classes generated for the automated unit testing are inherited from the namespace Microsoft.

Manual test Manual testing is the oldest and the simplest type of testing, but yet very crucial for software testing. It requires a tester to run all the tests without any automation tool. It helps us to validate whether the application meets various standards defined for effective and efficient accessibility and usage. Manual testing comes to play in the following scenarios: 1.

There is not enough budget for automation. The tests are more complicated, or are too difficult to be converted into automated tests. The tests are going to be executed only once. There is not enough time to automate the tests. Automated tests would be time-consuming to create and run. Manual tests can be created either using a Word document or Text format in Visual Studio This is a form of describing the test steps that should be performed by the tester. The step should also mention the expected result out of testing the step. Web tests can be created by recording the interactions that are performed in the browser.

These can be played back to test the web application. Web tests can be used for testing the application performance as well as for stress testing. During HTTP requests, the web test takes care of testing the web page redirects, validations, viewstate information, authentication, and JavaScript executions. There are different validation rules and extraction rules used in web testing. The validation rules are used for validating the form field names, texts, and tags in the requested web page. We can validate the results or values against the expected result as per business needs.

These validation rules are also used for checking the time taken for the HTTP request. At some point in time, we need to extract the data returned by the web pages. We may need the data for future use, or we may have to collect the data for testing purposes. In this case, we have to use the extraction rules for extracting the data returned by the page requested. Using this process, we can extract the form fields, texts, or values in the web page and store it in the web test context or collection.

Web tests cannot be performed only with the existence of a web page. We need some data to be populated from the database or some other source to test the web page functionality and performance. There is a data binding mechanism used in Web test, which is used for providing the data required for the requested page. We can bind the data from a database or any other data source. For example, the web page would be a reporting page that might require some query string parameters as well as the data to be shown in the page according to the parameters passed.

To provide data for all these data-driven testing, we have to use the concept of data binding with the data source. Web tests can be classified into Simple Web tests and Coded Web tests. Both these are supported by VSTS. It executes on its own as per the recording. Once the test is started, there won't be any intervention. The disadvantage is that it is not conditional. It's a series of valid flow of events.

For example, if we need some conditional execution of tests based on some values then we have to depend on this coded web test. These tests are created using either C or Visual Basic code. Using the generated code we can control the flow of test events. But the disadvantage is its high complexity and maintenance cost. Load test Load testing is a method of testing used in different types of testing. The important thing with Load testing is that it is about performance.

This type of testing is conducted with other types of testing, which means that it can be performed along with either Web testing or Unit testing. The main purpose of load testing is to identify the performance of application based on different scenarios. Most of the time, we can predict the performance of the application that we develop, if it is running on one machine or a desktop.

But in the case of web applications such as online ordering systems, we know the estimated maximum number of users, but do not know the connection speeds and location from where the users will access the web site. For such scenarios, the web application should support all the end users with good performance irrespective of the system they use, their Internet connection, the place, and the tool they use to access the web site. So before we release this web site to the customers or the end users, we should check the performance of the application so that it can support the mass end user group.

This is where load testing will be very useful in testing the application along with Web test or Unit test. When a Web test is added to a Load test, it will simulate multiple users opening simultaneous connections to the same web application and making multiple HTTP requests. Load testing in Visual Studio comes with lots of properties which can be set to test the web application with different browsers, different user profiles, light loads, and heavy loads.

Results of different tests can be saved in a repository to compare the set of results and improve their performance. In case of client server and multi-tier applications, we will be having a lot of components which will reside in the server and serve the client requests. To get the performance of these components, we have to make use of a Load test with a set of Unit tests. One good example would be to test the data access service component that calls a stored procedure in the backend database and returns the results to the application that is using this service.

A rig consists of a single controller and one or more agents. Load tests can be used in different scenarios of testing: 1. Stress testing: This checks the functionality of the application under heavy load. The resource provided to the application could vary based on the input file size or the size of the data set, for example, uploading a file which is more than 50MB in size. Smoke testing: This checks if the application performs well for a short duration with a light load. Performance testing: This checks the responsiveness and throughput of the application with different loads.

Capacity Planning test: This checks the application performance with various capacities. We will see more about setting the Load test properties, working with test rig and analysing the Load test results later in this book. Ordered test As we know, there are different types of testing required to build quality software. We take care of running all these tests for the applications we develop. But we also have an order in which to execute all these different tests.

For example, we do the unit testing first, then the integration test, then the smoke test, and then we go for the functional test. We can order the execution of these tests using Visual Studio. Another example would be to test the configurations for the application before actually testing the functionality of the application. If we don't order the test, we would never know whether the end result is correct or not. Sometimes, the tests will not go through successfully if the tests are not run in order.

Ordering of tests is done using the Test View window in Visual Studio. We can list all the available tests in the Test View and choose the tests in the same order using different options provided by Visual Studio and then run the tests. Visual Studio will take care of running the tests in the same order we have chosen in the list. So once we are able to run the test successfully in an order, we can also expect the same ordering in getting the results. Visual Studio provides the results of all the tests in a single row in the Test Results window.

Actually, this single row result will contain the results of all the tests run in the order. We can just double-click the single row result to get the details of each tests run in the ordered test. There are situations where we might end up having other applications for testing, which are not developed using Visual Studio. We might have only the executables or binaries for those applications. But we may not have the supported testing tool for those applications. This is where we need the generic testing method. This is just a way of testing third-party applications using Visual Studio. Generic tests are used to wrap the existing tests.

Once the wrapping is done, then it is just another test in VSTS. Using Visual Studio, we can collect the test results, and gather the code coverage data too. We can manage and run the generic tests in Visual Studio just like the others tests. Test management and new testing features in VS Visual Studio Team has great features for working with the type of tests we've just described. These features are greatly improved from the previous versions of VSTS.

Using this explorer, the developer or a user of Visual Studio can browse through the Team Projects in the TFS to which the explorer is connected. TFS is the central repository for managing and controlling the team projects. After connecting to the server, we can use Team Explorer to browse through the details of the particular Team Project. This process guidance helps the team follow the process for the Team Project items such as work items, reports, queries, and work products.

Importing and exporting the work items. Accessing the project files and source control management.

MOC 6214 Effective Team Development Using Microsoft Visual Studio Team System

Adding, removing, configuring, and managing the Team Projects. Creating, managing, and automating the project builds. Managing favorites which are shortcuts to the favorite nodes of the Team Project. Managing the reports. It could be defect reporting or any type of work items reporting. Team system testing tools introduction Visual Studio provides many tools to create, run, debug, and view results of the tests for the applications.

It is very flexible for running a test and getting the results. Given below are an overview of the tools and windows provided by Visual Studio to view the test details and test output details. We will look into more details of the actual usage of these tools later in Chapter But here, we will look into the overview of each of the tools available in Visual Studio We will not go into the details of the sample application TestingApp as shown in the preceding screenshot.

We will just create a test project for the sample application and see the features of the tools and windows. Now similar to adding the projects and code files to the solution, we have to create the test project and test files and add the test project to the solution. There are different ways of creating test projects under the solution. Select the solution and add a project using the Add New Project Then select the project type as Test from the list of project types under the language, which we are going to use.

Then select the template as Test Project. Select the solution and then from the top toolbar menu option, select the option Test New Test Now you can select the type of template we need for the testing. For our sample testing application, we will select the second option mentioned above and choose the simple Manual Test text format type. There are two different templates for the Manual Test with one using Text file and the other using a Word document. Following are the file extensions for each of the VSTS test types as shown in the preceding in the image.

We will see more details about this later. For now, consider that we have added the testing project to the existing solution. Let us name it TestProjectforTestingApp. Now, we can notice that there are two files created as. The metadata file contains all the information about the tests list. It is an XML file which has all the details.

Add two more tests of any type you want. Now, let us see the different windows and tools available in support of all the tests that we can perform using Visual Studio. We will take the sample Manual testing example for getting to know about the tools. Test view The Test View window is used for viewing the available tests and also for selecting the test and run it. We can also see the properties of each test from here. It is similar to the solution explorer from where we can get the list of class files in the project.

We can also group the available tests based on the type, or owner, or project, or solution, or priority, or any other property of the test. Now, you can see the following Test View screen which displays a list of all the tests created in the current Test Project. We can customize the test view using the filters, grouping and adding or removing the columns which we are going to see in the coming paragraphs. The Test View window has its own toolbar for different operations that can be performed on the list.

The left-most option in the toolbar is the run and debug option, by which we can start the VSTS process for running or debugging the selected tests. The second is the Filter option in the toolbar, which contains a drop-down listing of all the columns related to the Test View and the test properties and a box which says for entering the value that can be used against the field selected in the second drop-down for filtering the list of tests shown. When the button with the arrow next to these drop-downs is clicked, the actual filtering will take place, and the grid will show the filtered list of tests.

For example, the following image shows a list of tests filtered with Test Type which are Manual. In the preceding screenshot, remove the criteria entered for the filter in the second drop-down and click on the arrow which will show all the available tests. Now select any of the values available in the Group By drop-down.

On selecting the drop-down, we can see the list groups based on the value of the property selected in the drop-down. The three screenshots below show the tests grouped based on the type. We have two Manual tests and one Unit test. Here the class name is no name because the manual tests will not have any classes. Same is the case when we select Description as the Group By field as shown in the third screenshot below.

The test which is of type Unit test, and the test which is of type Manual Test are shown together because both these tests do not have a description. The screenshot below shows the tests grouped by Test type. There are two manual tests and one Unit test. The Manual tests does not have class name as it is not derived from any class and does not have a class. The below screenshot shows the grouping of tests based on the description. The unit test has a description but not the manual tests as there is no description for tests which is of type Manual [ 23 ] Visual Studio Team System Test Types We can change the descriptions of the tests and group them together.

Whenever we change the description or class name or an editable property of the test, it will be grouped under that property, if it exists. Otherwise, it will be shown as a new property with that new group. For example, if we change the description of all the tests to Sample Test and group the tests by description, then we can see all the tests grouped together as shown here: In the Test View, we can select the available columns to display in the view, and we can also sort them using the column header.

The following steps explain how to show a column in the view display and how to sort them: 1. Check and uncheck the columns that need to be displayed, and those that are not to be displayed. If the same column is already sorted, then the sorting order will be changed. Test list editor All features available in Test View are also available in the Test List Editor with some additional features. Through this window, we can create the test lists by grouping the available tests.

We can also select multiple tests from the list and run them using this window. Whenever we open the Test List Editor using the menu option Test Windows Test List Editor, we can see the window as follows showing all the available tests: The toolbar in the Test List Editor window has the same features that we saw in the Test View window. But you can see that the details section of the list window is split into two panes.

The left pane of the window has three nodes, and the right pane displays all the tests in the lists based on the selection in the left pane. The Test List Editor displays the following three options as nodes. Lists of tests This is the first node in the list which is initially empty.

It also asks us to create the list and add the tests to the list [ 25 ] Visual Studio Team System Test Types We can click on the here link and give the details for the new test list in the window that opens up as Create New Test List. Let's call that test list Manual Tests to group all the available manual tests. Do not check the option but just select the option. This will display all the available tests in the project, which are not part of any other Test list as shown below: [ 26 ] Chapter 1 Now choose both the Manual tests on the right pane and just drag and drop them on the Manual Tests node on the left pane, which we created earlier.

The other way of doing the same is, after selecting both manual tests, by right-clicking and choosing the New Test List.. We will get a window similar to what we saw earlier in Create New Test List. Since we have already created the Test list, we will just drag and drop the tests on the test list name. Now when we select the newly created Manual Tests list, we can both the manual tests listed on the right-side pane. Select the third node in the left pane All Loaded Tests. This option will list down all the tests available, whether it is added to a Test List or not.

We can also see the Test List name to which a particular test is added; and it will remain empty for the tests which are not part of any of the Test Lists. The following screenshot shows all the loaded tests in the project: After creating the Test List, we can run the tests based on the list we have created. The purpose of creating the Test List is to group the tests together so that we can run them all together by selecting the Test List using the checkbox option to the left of the test list name and then selecting the Run or Debug option in the toolbar.

Each of the nodes in the Test List Editor has checkboxes. Using these checkboxes, we can select the individual tests, a Test List, multiple tests within the Test list, and tests that are not in a list. These are helpful in loading the existing Test Lists, which are already saved but not available in the current list. This Import and Load refer to the metadata file that gets created for the Test Project under the solution. It's the file with the extension vsmdi, which contains all the information about the tests lists. All other options in the toolbar are the same as the options available in the Test View window such as grouping, filtering, and adding or removing columns.

Test results This window shows the results of the tests run. It shows the error messages or the statuses of the multiple tests run. We can also reselect the tests from the Test Results window and rerun the tests. Using this window, we can export the test results or import the results already exported. This is useful in viewing the result in the Test Results window and rerun the test. Now, as we have seen in the previous section about the Test List Editor, select the Manual Tests list and run the tests.

But for now, we will consider the test, manualtestdoc as passed, and the test ManualTestText as failed. While running the tests, we can find the tests in progress and the status of the completed tests in the Test Results window as shown below. It's just the starting of the tests. So both the tests are in pending stage. After completing both the tests, we can see the results as shown in the following screenshot. It will clearly indicate the status for each result.

  • Iconoclastic?
  • Introduction.
  • Popular Tags.

The window also shows the summary of the results, passed and failed. If we want to rerun the test, we don't need to go to the List Editor. From the results window, we can select the tests and rerun them. Using the checkbox before the test in the list window, we can select the test and then choose the Run or Debug option to rerun it.

In the preceding screenshot, we can also notice that there are two panes similar to the Test List Editor. The second option in the toolbar shows the list of Test Lists available and their corresponding tests in the right pane. It is the same option that we saw in the Test List Editor. From the test result, we can also get the details of the test list run. We can get the details such as start time, end time, test location, and the user who ran the test and also the summary of the test results as shown in the following screenshot: [ 30 ] Chapter 1 There is another option in the Test Results, which is the option to export the results.

Whenever we finish our testing, we always would want to save the results of the tests for our further analysis. In the toolbar, we can see the option for exporting the test results. It provides two options, Export Test Run Results We can also import the saved result using this window. Refer Chapter 10 for more details about the export and import functionality.

Once we choose any of these options, we can see the file dialog for saving the file. The file is named after the user, machine name, the date and time of execution. If you open the. The contents of the test result file would look like the code shown below. This is to view the statistical information about the test run.

This result will show how many lines of code are executed and how many lines are not executed. We can also get the color coding for the lines run, and different color coding for the lines not run. This is also a kind of test result. Before starting the code coverage we have to configure the code coverage.

These configurations are stored in the configuration file, localtestrun. In the configuration window, select the option Code Coverage in the left pane. On the right-side pane, we can see the list of all the available artifacts for code coverage. The artifacts could be an application, or a library, or any type of assembly. We can choose the artifacts from the list, or we can also import the artifacts using the Add Assembly option and then choose that for the code coverage.

As shown in the following screenshot, let us select the test project library, TestProjectforTestingApp. When the application is executed, we can see the code coverage window collecting information about the source code covered in testing as shown in the following screenshot. Lets try running the unit test application available in the test list editor under the Tests Not in a List which has the Unit test. After running the test, we can see the code coverage results as shown in the following screenshot: The Code Coverage Results window shows each block covered, blocks not covered, and the percentage of coverage for blocks.

This applies to each run of the test. Next time we run the same test, we can see a different set of results under a new name. We can see more about how we can run the Unit test and analyze the code coverage in the next chapter on Unit Tests. In the Unittest1 class, we can also notice the color coding based on the coverage. This is the code which is covered under testing, and code that is not covered will be highlighted with color coding.

After completing the test, we can also export the coverage results similar to the test results. We can also import the coverage results which were already exported. There is another new option, Merge Results. This window will list all the coverage results from which we can select the results and merge them to get the end result of the code coverage collectively from various results. All these documents should conform to the schema defined in the TestTypes. We have seen some of the XML document types in the previous examples, and here is the summary of all the XML documents for different test types supported by Visual Studio.

Each of these is explained in detail in the individual chapter that explains the type of test. Test Metadata file: This file stores information about all the tests in the solution. It has the extension. Test Results file: This file contains the results of the tests that were run. This file will be created automatically by Visual Studio when any test is run. Test Run Configuration file: This file contains the settings that specify how the test runs should proceed further.

There are other XML files for different test types with some specific extensions such as. This file accepts one parameter which is the XML document for the test created using Visual Studio We have also looked at how we can create the test project in Visual Studio, and how we make use of different tools that support testing in Visual Studio. Now, we should be able to create and execute a test project and create the test lists. We got an idea of how to view the test results using the Test Results window and look into the Code Coverage Results window. This chapter also explained about different types of XML and configuration documents that were created during the testing.

Now, we should be able to convert our existing testing application created using Visual Studio to the Visual Studio format using the converter tool, which we saw in this chapter, and continue our testing. The later chapters will discuss in detail about conducting different types of testing using Visual Studio In project development, there may be many modules and each module comprises a set of code or functionalities. Identifying the piece of code in the module, which causes the defect is always a time-consuming task and the cost involved is also more.

It is always better to test the code in units and confirm the functionality before integrating the code into module s. Requiring all code to pass the unit tests before they can be integrated ensures that the functionality always works. Make sure each unit of code is written for one piece of functionality so that the result produced by each unit test is for a single functionality.

Every time a defect is fixed or code is modified, we don't have to manually retest the unit, spending a lot of time and money. The automated unit test will help us make sure the functionality is unaffected. VSTS is used for generating the unit test for the methods irrespective of whether they are public or private. Unit test is another class file similar to any other class and methods having additional attributes to define the Test class and the Test method. The unit tests can be created either by manually writing the code or by generating the unit test code using the Create Unit Tests option from the context-menu in VSTS.

The generated unit test class contains special attributes assigned to the class and methods in the class. Test classes are marked by the attribute [TestClass ] and each test method is marked with the attribute [TestMethod ]. Apart from these two, there are many other attributes used for unit testing.

After generating the unit test class and methods, we can use the Assert method to verify the produced result with the expected value. All of the unit test classes and methods are defined in the namespace Microsoft. Whenever we create a new unit test in Visual Studio, we have to include this namespace to the class file. One of the main properties of the test classes in unit testing is the TestContext which holds all the information about tests. Unit Testing Creating unit tests There are two different ways of creating a unit test. One is the manual way of writing the code and the other is to generate the unit test code for the class using the option in Visual Studio.

To see how a test class is generated, let us consider the class library below, following which is a very simple example of total price calculation. Generic; System. Linq; System. Right-click on the CalculateTotalPrice method, which will show up on the dialog for creating the unit testing. The selected method will be checked in the list leaving the other methods unchecked, which means that the unit test will be generated only for the selected method in the list.

We can select and unselect any number of methods in the list based on the requirements. Choose the required option and provide a new name for the test project if the selected option is for a new project. Double and GetTotalPrice. Now Visual Studio creates a new class file for the selected method's class. We can see the class name as Class1 in the previous screenshot. So the test class created for this would be Class1Test. While creating the unit test, we can change the settings using the option in the Create Unit Tests window.

These settings are used for changing the way of creating the unit tests by changing the file name, unit test class names, and the method name generation. The settings also enable and disable some of the standard code and method attributes that generates by default for all the unit test code. The following two sections explain in detail about the settings that may be used during unit test code generation. The [Class] will be replaced with the actual class name at the time of generating the code. If required, we can add our own text in addition to the name. We can customize the class name as we want if we don't like the default name suggested by the tool.

The [Method] is replaced with the actual method name at the time of code generation. General settings These are the general settings applicable for the default basic code generated for each unit test. Using this we can enable or disable some of the common code generated for the classes.

Inconclusive statement is added to all the methods in the unit test class. This is useful to specify the method is incomplete, as we have not added any test code yet. The method only contains the skeleton of the auto-generated test method. Later on, once we add the actual test code to the method we can safely remove this Assert. Inconclusive call. Inconclusive "Verify the correctness of this test method. This will help us resolve the issue and add the code later on. The unit test code may contain multiple class file test methods.

Sometimes the same type may be used in different class files. So to make sure the types are unique across the test, the namespaces are added to all the types in the test.

Visual Studio Team System

The comments are in XML format by default. The default comments can be modified or added with more comments describing the test method. If this option is disabled, the comments won't be generated for the test methods. MethodforInternalExample str ; Assert. AreEqual expected, actual ; Assert. The Add assembly option helps us select the assembly to be added and then displays the methods and classes from the assembly. We can select the methods from the tree view and then generate the unit test. You may also notice that the Assert. Inconclusive call is added to all the methods by default based on the settings.

VSTS also adds the default start up and cleaning methods, which we can make use of for testing. The following are the list of attributes used for test class and test methods: Attributes TestClass Description ClassInitialize The method with this attribute is used for preparing the class for the test; for example, setting up the environment or collecting details which are required for testing are handled within this method; the method with this attribute is executed just before the first test in the class; each test class can have only one method as the class initializer.

ClassCleanup The method with this attribute is used for cleaning or destroying the objects used in the test; this method is executed after all the tests in the class are run; test class can contain only one method as the ClassCleanup method. TestInitialize The method with this attribute is used for initializing or running the code before each test. TestCleanup This method is run after each test in the class; this is similar to the ClassCleanup but the difference here is that the method is executed once after each test. TestMethod This attribute identifies the method to be included as part of the test; this method has the unit test code for the method in the original class file.

To identify the unit test class within the file. In the following code, we can see many attributes and properties set to the class and methods. Visual Studio by default creates some methods with special attributes which are commented. If these methods are required for testing, we can uncomment it and make use of it.

GetTotalPrice ; Assert. CalculateTotalPrice quantity ; Assert.

  1. Representations of Femininity in American Genre Cinema: The Womans Film, Film Noir, and Modern Horror.
  2. Azure DevOps (formerly Visual Studio Team Services).
  3. MOC 6214 Effective Team Development Using Microsoft Visual Studio Team System.
  4. The exceptions thrown from the Finalizer method will not be caught leading to unexpected result. The cleanup activity should be used for bringing the environment to its original state. For example, during testing we might have updated or inserted more records to the database tables or would have created lot of files and logs. This information should be removed once the testing is complete and the exceptions during this process should be caught and rectified.

    Assert statements The assert statement is used for comparing the result from the method with the expected result and then passing or failing the test based on the match. Whatever may be the result produced by the method, the end result of the test method depends on the return value of the assert method.

    The assert statement takes care of setting the result. There are different statements supported by the Assert class to set the return value to Pass or Fail or Inconclusive. If the assert statement is not present in the test method, the test method will always return a Pass. If there are many assert statements in the test method, the test will be in Pass state until one of the assert statements returns Fail. AreEqual and Assert. The Assert. AreEqual has two parameters—one as expected which is the expected value that should be returned by the CalculateTotalPrice method and the other as actual indicating the actual value returned by the method.

    AreEqual statement, which is explained in detail in the next section, compares these two values and returns the test result as Pass if both the value matches. Returns Fail if there is a mismatch between these two values. Inconclusive statement to return the result as inconclusive if the test method is not complete. We can remove this line if the code is complete and we do not want the test result to be inconclusive.

    In the previous code, if we run the test without setting the value for quantity and expected the return would be Inconclusive. If you change the expected value to then the test would pass. We have seen only one type of assert statement. There are many other asserts, which we can use in test methods for passing or failing the test. The namespace Microsoft. The actual and the expected values are compared based on the type of assert used and the result decides the test pass or failure.

    The assert class The assert class has many different overloaded methods for comparing the values. Each method is used for a specific type of comparison. For example, an assert can compare a string with a string or an object with another object, but not an integer with an object. Overloaded methods are like the additional or optional parameters to the method in case we want custom messages or the additional functionality to be added. For example, the assert method provides an overloaded method to compare the values within a specified accuracy, which we will see in detail when comparing double values.

    Let us consider a simple Item class with three properties each with different data types. GetObjectToCompare ; Assert. AreEqual This is used for comparing and verifying actual and expected values. The following are the overloaded methods for the Assert. AreEqual and the result for the above code samples. Method Assert. The test fails because the actual and the expected are two different objects even though the properties are the same. AreEqual Object, Object, String Description Used for verifying two objects and displays the string message if the test fails; for example, if the statement is like this Assert.

    AreEqual expected, actual, "Not equal" The output if the test fails would be Assert. AreEqual failed. Objects are not equal Assert. AreEqual Object, Object, String, Object[] Used for verifying two objects and displays the string message if the test fails; the formatting is applied to the displayed message; for example, if the assert statement is like this Assert.

    AreEqual String, String, Boolean Used for comparing and verifying two strings; the third parameter is to specify whether to ignore cases or not; if the assert statement is like this Assert.

    Navigation menu

    AreEqual expected. ItemType, actual. ItemType, false The test will pass only if both the values are the same including the cases. AreEqual String, String. Boolean, CultureInfo Used for comparing two strings specifying cases to include for comparison including the culture info specified; for example, if the assert is like this Assert.

    ItemType, false, System. EnglishName If the property value for expected. AreEqual String, String, Boolean, String Description Used for comparing two strings specifying casing to include for comparison; display the specified message if the test fails; for example, if the statement is like this Assert. ItemType, false, "Both the strings are not equal" The test result would be Assert. Both the strings are not equal Assert.

    AreEqual String, String, Booelan, CultureInfo, String Used for comparing two strings specifying casing and culture info to include for comparison; displays the specified message if the test fails the following is an example, Assert. AreEqual String, String, Booelan, String, Object[] Used for comparing two strings specifying the casing; the specified message is displayed with the specified formatting applied to it; for example, if the statement is like this Assert.

    ItemType, expected. ItemType Assert. ItemType ; The test result if the test fails would be Assert. Both the strings 'Electronics' and 'electronics' are not equal [ 50 ] Chapter 2 Method Assert. AreEqual String, String, Booelan, CultureInfo, String, Object[] Description Used for comparing two strings specifying casing and culture information to include for comparison; display the specified message if the test fails; the specified formatters are applied to the message to replace it with the parameter values.

    The following is an example, Assert. Itemtype and expected. AreEqual Single, Single, Single, String These are the three different overloaded assert methods for comparing and verifying the Double values; the first and second parameter values are the expected and actual values; the third parameter is to specify the accuracy within which the values should be compared. The fourth parameter is for the message and fifth is the formatter to be applied for the message; for example, if the assert is like this Assert. ItemPrice, actual.

    ItemPrice, 0. ItemPrice ; The test would produce a result as Assert. Expected a difference no greater than between expected value and actual value. The value Here the expected accuracy is 0. This is very similar to the Double value comparison as shown above but the values here are of type Single; this method also supports the message and the formatters to be displayed if the test fails.

    AreEqual T, T, Assert. AreEqual T, T, String, Object[] Description These overloaded methods are used for comparing and verifying the generic type data; the assertion fails if they are not equal and displays the message by applying the specified formatters; for example, if the assert is like Assert. The objects 'actual' and 'expected' are not equal Assert.

    AreNotEqual All the above said overloaded methods for Assert. AreEqual also applies to Assert. AreNotEqual but the only difference is that the comparison is the exact opposite of the AreEqual assert. For example, the following method verifies if the two strings are not equal by ignoring or not ignoring the casing as specified by Boolean. The test fails if they are equal and the message is displayed with the specified formatting applied to it. AreNotEqual expected. ItemType ; If the string values are equal, the output of this would be: Assert.

    AreNotEqual failed. Both the strings 'Electronics' and 'Electronics' are equal [ 52 ] Chapter 2 Assert. AreSame Method Assert. AreSame Object, Object Description This method compares and verifies whether both the object variables refer to the same object; even if the properties are the same the objects might be different; for example, the following test will pass because the objects are the same. AreSame failed. The objects expected and actual are not same [ 53 ] Unit Testing Method Assert. The objects A and B are not same Assert.

    AreNotSame This assert is used for verifying whether the two objects are not the same. The test fails if the objects are the same. The same overloaded methods for Assert. AreSame applies here as well, but the comparison is the exact opposite. Following are the three overloaded methods applied to Assert.

    If they are the same, the test fails with the specified error message with the specified formatting applied to it. AreNotSame failed. The test fails because the objects A and B are same. Fail This Assert is used for failing the test without checking any condition. Fail has three overloaded methods. Fail Description Assert. Fail String Fails the test without checking any condition and displays the message Assert.

    Fail String, Object[] Fails the test without checking any condition and display the message with the specified formatting applied to the message; for example, the following code does not check for any condition but fails the test and displays the message Fails the test without checking any condition Assert. Fail failed. This method 'GetItemPrice' is set to fail temporarily Assert. Inconclusive This is useful in case the method is incomplete and we cannot determine whether the output is true or false. We can set the assertion to be inconclusive until we complete the method for testing.

    There are three overloaded methods for Assert. Inconclusive Description Assert. Inconclusive String Assertion cannot be verified; set to inconclusive and displays the message Assert. Inconclusive String, Object[] Assertion cannot be verified; set to inconclusive and displays the message with the specified formatting applied to it; for example, the following code sets the assertion as inconclusive which means neither true nor false Assertion cannot be verified; set to inconclusive Assert.

    Inconclusive failed. IsTrue This is used for verifying if the condition is true. The test fails if the condition is false. IsTrue Description Assert. IsTrue String Used for verifying the condition and display the message if the test fails with the condition false. IsTrue String, Object[] Verifies the condition and display the message if the test fails with the condition false; apply the specified formatting to the message. Used for verifying the condition; test fails if the condition is false For example, the following code fails the test as the conditions returns false.

    IsTrue failed. Both 'A' and 'B' are not equal Assert. IsFalse This is to verify if the condition is false. The test fails if the condition is true. Similar to Assert.

    Load Test with Visual Studio Team System

    IsTrue, this one has three overloaded methods. IsFalse Description Assert. IsFalse String Used for verifying the condition; display the message if the test fails with the condition true. Used for verifying the condition; test fails if the condition is true. IsFalse String, Object[] Description Verify the condition and display the message if the test fails with the condition true and apply the specified formatting to the message. For example, the following code fails the test as the conditions returns true. IsFalse failed.

    Both 'A' and 'B' are equal Assert. IsNull This is useful in verifying whether the object is null. The test fails if the object is not null. Given here are the three overloaded methods for Assert. IsNull Object Description Assert. IsNull Object, String Verify if the object is null and display the message if the object is not null and the test fails. IsNull Object, String, Object[] Verify if the object is null and display the message if the object is not null; apply the formatting to the message Verify if the object is null. IsNull failed. Object 'B' is not null. IsNotNull This is to verify if the object is null or not.

    The test fails if the object is null. This is the exact opposite of the Assert. A testers perspective in what needs tested will differ from a developers so the combination of the two creates very rigorous unit tests. So we now have during unit testing, the functional testing and automated regression testing happening very early in the project. Unit tests can be used in load testing. One example is login where UserID and Password are entered.

    What is the savings in knowing during development that the system is not going to have problems with 1, concurrent logins? Add this test to the build regression tests and you know throughout your project how well it is standing up to load. Why leave load testing to the end, do it early and save time, money and possibly the project. Very impressive and it can be run against code by testers saving development time for development. Check out the link above for a white paper on PEX. Maybe Microsoft will make a version of PEX that testing can use which does not require us to have access to the actual source code.

    And you are not testing alone, it is a group effort and it is the route to success. Presentation Slides. We teamed up doing a session at the conference. Bruce wowed the crowd with a demo of his test-driven development skills and the Microsoft Research tool Pex Automated Whitebox. Net testing tool. As we promised the presentation slides can be downloaded see link below. Never Test Alone presentation slides. Research Microsoft Pex. There are not many conferences on Software Testing that are held here in Canada, well this year a big one is.

    If your interested in speaking the Call for Papers deadline is February 4th, To see more information on the conference click this link CAST Tuesday Jan. Click the link for details about this presentation including a link for registration. VS Team System Orcas has improved validation rules. Test-level validation rules allow you to add the same rule to every request by simply clicking the Web test node and selecting Add Validation Rule. A dialog box opens select the validation rule, in the properties you can edit or add options and parameters.

    Reasons for using a test-level rule:. Listed below are new validation rules:. If you watch the video the value AJAX adds is pretty impressive. Web Testing. Load Testing.