. NET Assembly Unit Test Tool SmokeTest Application Guide

Source: Internet
Author: User
Tags reflector net domain

Smoke Test (smoke test), also known as regression test (regression testing), is a test of the installation and basic functionality of the software. In general, we use scripts to automate smoke test, borrowing the snapshot mechanism of a virtual machine to ensure a clean environment for smoke test, and then integrating the tested program into the continous build or daily build.
Smoke test refers to a basic functional test, which is borrowed from the hardware test. Hardware testing, the first need to add power to the hardware, if a power circuit burning smoke, the subsequent test of course does not go, that is, can be power-up is the precondition for testing behind. Reference to the software is only the basic function of the software is correct, the subsequent development and testing can be carried out. Smoke tests are generally implemented in conjunction with daily builds.

The tool name to be recommended to readers today is called SmokeTest, which is an assembly test tool in the. NET domain, which is an assembly-unit test tool.

The official introduction to SmokeTest is as follows:

SmokeTest lets you invoke any member of a class interactively. An indispensable tool for anyone involved in developing, testing, and managing Windows. NET projects.

The address is as follows: http://smoketest.wesleysteiner.com/

SmokeTest allows us to test a method in an assembly without writing any code. Using this tool, we can create an object's entity (call the constructor method), invoke the method, get or set the property, and manipulate the result of the call.

Create an instance of any Class create an object entity (call constructor method)
Call any method invocation
get and set any property gets or sets the property value
Read and write any field to read or SET field values
Create and edit object instances to pass as arguments create and edit an entity and pass it to the parameters of the method
Drill-down and smoke-test The returned result drillthrough returns a result set

A testable type (smoke-testable) must be a value type (ValueType) or a reference type (class) that does not support testing of generic classes or interfaces.

1 testing. NET DateTime type methods and properties

In the tree structure on the left, browse to Mscrolib under the System namespace, click the DateTime node, click DateTime.Now in Properties

See the yellow form at the bottom right of the current time of the output system.

Then go to the Methods Method tab in test Isleapyear, enter parameter 2016, click the Call button and see output True in the right bottom result form.

2 Test no Return value method
public static void Add ()
{
   Console.WriteLine ("Test");
}

The output form returns (null), indicating no return value.

3 Testing the method of adding two integers
public static int Add (int a, int b)
{
   return a + B;
}

We enter parameter 1, 2 in the parameter bar, and see the output form return result 3.

4 The parameter of the method is the object type
public static int ExecuteScalar (SqlConnection connection, CommandType commandtype, string commandtext)
{
    Pass through the call providing NULL for the set of SqlParameters
    return ExecuteNonQuery (Connection, CommandType, CommandText, (sqlparameter[]) null);
}

Our first parameter is the SqlConnection object, and the second argument is the enumeration type. When this method is selected, the Parameters form resembles the following.

Click on the button after the first parameter SqlConnection, open the form to select the construction method with parameters, fill in the connection string information click the Create button

Close this form, return to the main form, and enter the SQL statement represented by the Comandtext parameter

SELECT company_name from dbo. Gbparm

When you click the Call button, you see the result output form showing the return value in the database.

As you can see from this step, SmokeTest has the ability to instantiate parameters by passing values to the parameters to create an instance of the parameter, thus passing the parameter values of the method being tested.

5 The return result of a method is a collection type or object type
public static DataSet ExecuteDataset (SqlConnection connection, CommandType commandtype, string commandtext)
{
   Pass through the call providing NULL for the set of SqlParameters
   return ExecuteDataset (Connection, CommandType, CommandText, (sqlparameter[]) null);
}

The return type of this method is a dataset, and the resulting output window displays after execution

By clicking on the DataSet button on the right, we can manipulate the return value of the ExecuteDataset method. Following the alphabetical order in, click, Cocoa observes that the 3rd form (intermediate form) returns a result of 1, which is exactly the number of table that the dataset that is returned by the SQL statement above is called.

If the DataSet button can display data in a visual way (DataGridView control), it is more complete.

6 repeating n calls test mode

Note that the call button above has an X 1 drop-down option, with 1-1000000 options inside. The default point X1 means that the test method is called once, and if you choose a different value, you can call Test mode n times. There are currently several option values:

In the drop-down box below, the time spent on each call is recorded and the call order is called.

7. NET Reflector Plug-in

SmokeTest's author also designed the. NET Reflector plugin for it, with the help of. NET Reflector well-designed assembly browsing capabilities, while viewing the source code, edge test method.

Plugin: Http://smoketest.wesleysteiner.com/smoketest_raddin_1_0.zip

8 NUnit, MS Test, Testdriven.net,smoketest

The first two types of programming code that need to be written are the main tools in the. NET unit testing area.

Nunit
[Testfixture]
public class Usertest
{
   [Test]
   public void Logintest ()
   {
       User user = Sessionmanaer.login ("admin", "cnblogs");
       Assert.istrue (User!=null);
    }
}
MSTest
[TestClass]
public class Usertest
{
   [TestMethod]
   public void Logintest ()
   {
       User user = Sessionmanaer.login ("admin", "cnblogs");
       Assert.istrue (User!=null);
    }
}

TestDriven.NET is an extension tool built on NUnit or MSTest technology that enables you to run tests directly in any method, class, source file, namespace, or project.

Note that the method of testdriven.net testing does not necessarily require the test or TestMethod feature (attribute), you only need to click the test button inside a method to complete the code test.

SmokeTest is a code testing tool based on. NET assemblies, using SmokeTest does not require writing code, only requires its parameter generation tool, filling in parameter values to perform static methods or properties testing.

. NET Assembly Unit Test Tool SmokeTest Application Guide

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.