Using the ideology and Java reflection (reflect) technology, build a flexible, reasonable system (5)

zhaozj2021-02-17  60

Use the idea of ​​the class and the reflection of Java, build a flexible, reasonable system

- Write to Java beginners

Third, the design of the automated test

Now, we will analyze the few abstract classes mentioned earlier: WebAction (a representative class), Validate (a representative verification abstraction) and Condition (a representative verification condition). First, let's analyze the Abstract Class of WebAction. Since we have defined it as an abstract class that represents the web interaction, we can consider what web interactions will it be? 1. It will have a constructor behavior, which is reflected in his constructor (we have already analyzed in front); 2. It will have specific behaviors that perform web interaction (we will introduce later); 3, because this It is an automated test system, so it also has the function of performing validate. WebAction is an abstract class representing the web interaction (Abstract Class), and the way to interact with the web is a variety of ways, except that the geturi mentioned above may have PostForm. Then, different interactions must have different interactions. So, we can define such an abstract way in the abstract class: public abstract void runtest (); there is a specific class that implements its specific classes (such as geturi, postform, etc.) must write themselves RunTest method. What is the benefit of doing this? We will see it immediately! Next, let's analyze the abstract class, we can imagine that since it is verification, then there will definitely have the case of success (Success) or a failure; but no matter what situation, they have A common, method of need to execute: RunValidate; then we must put this RunValidate in the abstract class Validate, not to put it in a specified verification result, such as : ValidatesUccess (Verify Pass) or ValidateFailure! However, performing verification is a condition, so performing verification, inventory, but, condition, we also define it as an abstract class; because of the verification Conditions more than one! As mentioned above, there may be other, such as: OtherexcePtsuccessCondition.

So, the specific execution code, we should put it in the Condition specific class to execute, declare a method in the abstract class: public abstract boolean runcondition (); then let all his sub-verification conditions class Go to specific implementation! For example, in responsecontaintext, this specific implementation of the Condition subclass, we can write our code: public boolean runcondition () {boolean passed = false; if (...) passed;}

Here, everyone should use the abstractract class. Using class ideas and Java reflex (Reflect) technology, build a flexible, reasonable system (1) http://www.9cbs.net/develop/read_article.asp?id=23408 use the idea of ​​using classes and Java Reflecting technology, constructing a flexible, reasonable system (2) http://www.9cbs.net/develop/read_article.asp?id=23409 Application class's ideology and Java reflection (reflect) technology, construction A flexible, reasonable system (3) http://www.9cbs.net/develop/read_article.asp?id=23410 Using the idea of ​​using classes and Java reflexes, build a flexible, reasonable system (4) http://www.9cbs.net/develop/read_article.asp?id=23411 Using the idea of ​​using classes and the reflection of Java, build a flexible, reasonable system (5) http: // Www.9cbs.net/develop/read_article.asp?id=23412 Using the idea of ​​the class and the reflection of Java (Reflect) technology, build a flexible, reasonable system (6) http://www.9cbs.net/develop /READ_Article.asp?id=23413

转载请注明原文地址:https://www.9cbs.com/read-30640.html

New Post(0)