Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Fitnesse use Series 2

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Decision table

Several table styles are available in Fitnesse, and as mentioned earlier, tables are the key to performing tests. Literally, the table describes the test case; from an execution perspective, the table provides the package name, class name, method name, and parameters for the back-end code (called fixture in fitnesse) (take java as an example only).

Let's start with the test system. Fitnesse provides two test systems: fit and slim. Using different test systems, the table style is different, the code is also different. So first of all, you have to decide which one to use. Fit is the default and is a continuation of the Framework for Integrated Test tool. If you do not consider the extension of the old code, it is recommended to use slim. Because slim is better in performance and easier to code.

To use slim, you need to add a line to the page:! define TEST_SYSTEM {slim}, usually at the top of the page

It's time to describe the class or jar package on which the code is executed. The format is generally written as follows:

! pathD:\ software\ eclipse\ workspaces\ MyDemo\ bin\ or

! pathD:\ software\ eclipse\ workspaces\ MyDemo\ libs\ * .jar (if you don't specify .jar, go to the .class file)

In last year's version, you also need to add fitnesse's own jar package to:! pathD:\ software\ fitnesse-standalone.jar, but in this year's version, I found that this sentence is no longer needed.

The style of the decision table:

My demoinputa

Inputbexp?1238917

This my demo is the class name of the code, and you know that identifiers with spaces are not allowed in most programming languages. Then it certainly won't work to use my demo in the code. Fitnesse actually does this-capitalize each word and then concatenate it. So the corresponding class name in the code is MyDemo. In this way, the effect of writing MyDemo, My demo and MyDemo here is the same. But not as mydemo, this can only be converted into Mydemo, I think I made myself clear. For the full name of the class (including the package name), it can only be written honestly according to the normal way, such as: com.calis.zjc.MyDemo, there can be no spaces, otherwise automatically converted to the first letter capitalization is not correct.

The next line is the method name. This is what Fitnesse does-- where not? At the end, it is considered to be an input method with no return value, and the method name is an uppercase string of set+ initials, that is to say, the corresponding method names in the above table are: void setInputa (...) and void setInputb (...), respectively. The column at the end is considered to be a validation method, and no parameters have a return value. The corresponding method name is int exp (). Why do you see that the return value type is int, in fact, it is unlimited. No matter what type is returned, it can be compared with the characters on the page, which is more intelligent (I don't see the source code, but I guess I get the return value and then equals all the .toString (), and then equals the string on the page)

To sum up: the code corresponding to the above table is:

Public class MyDemo {private int an int b; public void setInputa (int a) {this.a=a;} public void setInputb (int b) {this.b=b;} public int exp () {return aforb;}}

When we set the page property to test, click the test button, the system will find and load the class, and then run the corresponding method, that is, the first step is setInputa (int a), an is 1; the second step is setInputb (int b), b is 2; the third step exp gets the return value 3 to compare with the 3 in the table, consistent, this line is green, and inconsistency is red. Then do the second line, which completes the execution of the two test cases. (if the table is not filled with integers, then executing the assignment method will throw an exception, which should also be noted.)

By the way, the execution page is not just about tables. It is entirely possible to write other words without affecting the execution result. So we can write a specification of requirements, verify it with a table, write a description of the use of it, then write a table, describe a defect, and then follow a table. In this way, the page becomes both a document and an executable use case. In short, let the "text" be verified, is the highlight of this tool.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report