官术网_书友最值得收藏!

Understanding test case design patterns

Goal: Learn the basic patterns for designing tests.

If you have been testing software, you might know that each test has a similar overall structure. Before you can perform the action under test, for example, the posting of a document, first, the data needs to be set up. Then, the action will be exercised. And finally, the result of the action has to be verified. In some cases, a fourth phase applies, a so-called teardown, which is used to revert the system under test to its previous state.

The four phases of a test case design pattern are listed as follows:

  • Set up
  • Exercise
  • Verify
  • Teardown
For a short and clear description of the four-phase design pattern, please refer to the following link:
http://robots.thoughtbot.com/four-phase-test

This design pattern was typically the pattern used by Microsoft in the early years of C/SIDE test coding. Like the following test function example, taken from codeunit 137295 - SCM Inventory Misc. III, you will encounter it in a vast number of older test codeunits:

[Test] PstdSalesInvStatisticsWithSalesPrice()
// Verify Amount on Posted Sales Invoice Statistics
// after posting Sales Order.

// Setup: Create Sales Order, define Sales Price on Customer
Initialize();
CreateSalesOrderWithSalesPriceOnCustomer(SalesLine, WorkDate());
LibraryVariableStorage.Enqueue(SalesLine."Line Amount");
// Enqueue for SalesInvoiceStatisticsPageHandler.

// Exercise: Post Sales Order.
DocumentNo := PostSalesDocument(SalesLine, true);
// TRUE for Invoice.

// Verify: Verify Amount on Posted Sales Invoice Statistics.
// Verification done in SalesInvoiceStatisticsPageHandler
PostedSalesInvoice.OpenView;
PostedSalesInvoice.Filter.SetFilter("No.", DocumentNo);
PostedSalesInvoice.Statistics.Invoke();
主站蜘蛛池模板: 广饶县| 双江| 西林县| 米脂县| 新和县| 临安市| 贵定县| 遂平县| 浦北县| 江津市| 句容市| 南溪县| 乳源| 赣榆县| 平凉市| 朝阳县| 龙口市| 峨眉山市| 玉田县| 天镇县| 壶关县| 保亭| 绥化市| 合山市| 鱼台县| 博罗县| 庐江县| 长春市| 延边| 丽江市| 北海市| 日照市| 东乡| 德庆县| 建德市| 温泉县| 陆丰市| 浙江省| 温宿县| 望谟县| 合山市|