200828011 九、發明說明: 【發明所屬之技術領域】 特別是一種基於程序運行 [0 01 ]本發明係關於一種測試方法 域之私式測試方法。 【先前技術】 陶軟體職狀體開發流財的—個大環節。以測試型態 來做分類辆,可时舰_觀(CQnstruetiGn Testing)、系 統測試(System Testing)、以及特殊測試(Speciai 構性測試是屬於前置㈣職,主妓偏重於程式端的功能測 試,以確練式執行運作正常。_麟是屬种後期的整合測 試,所進行的測試是以使用者的觀點為主,也就是模擬外界的使 用者會如何的使用產品。至於特殊測試所指的是,所進行的測試 需要花費更多的時間與人力才能完成。 _]就測試模式而言,可分為自盒峨(職㈣⑽把邮) 與黑盒測試(BlackBoxTesting)。這兩種方式的測試方向是不同 的,白盒測試是㈣程序結構為主,而黑盒測試是以程式的功能 為主。 [004] 白盒測試也稱為結構性測試(Stmctural Testing),白盒 展N式有兩大層面·資料流程面(DataFlow Coverage)以及控制流 程面(Control Flow Coverage),資料流程面就是測試資料在系統 的進出入於程式内所經過的流程,控制流程面就是測試程式在執 行過程中每個階段的流程。 [005] 進行黑盒測試時,測試人員並不需要對軟體的結構性有 200828011 足夠深層的瞭解,所進行的測試是著重 有人稱之為功能測試。為了要控淑心功⑽:所以也 須要按照測試案例(Test Cases)來逐—進行;^ =人貝必 計的好壞就會直接影_戦結果。 es Cases设 [006]軟體項目有其不同其他項 視性、產品執絲_無姐、產品品崎^^域品的不可 致軟體產品品質报難完美保證。對於項=:完全性、導 ^ T貝㈢旱乂小的或者對品質要求 而言,手工方式—般也能達到預期的效果。但是隨 者產4統的不斷雜,魏的不斷增加,同咖戶對產品品所 要求的提高’導致必須考慮採__試方式方法去適應:二 求。 而 _]軟體產品的複雜性4致在幸墙產品整合及送交品質部 門剛開始測試時,大量的錯誤(bug)出現,這 程師、測试工程師、開發主管、測式主管、心^ 費大量的人力,物力等。 _]-般而言,在產品送測初期產生的bug佔到總bug量的 70-80%左右,因此如何快速的、自動化的提早發現這此bug,h 提南產品品質、縮短開發測試週期以及提高客戶滿意度的關鍵 [009]要檢驗開發的軟體是否有bug,可以採取各種不同的測 減朿略。但是’不論採用哪一種測試策略,設計測試方案都B、則 試階段最關鍵問題。測試以前都需要從程序定義域中選取有代夺 性的測試數據,這也是測試成功與否的關鍵。 【發明内容】 200828011 法。直主要提種基於程式運行域分析_試數據生成方 _二式功能域與運行域的測試數據自動 用程切刀斤母一個應雜源程式的變量類型,完成對應 2式力錢的取得,透獅朗程式本身運行語句進行分析, 触此轉取錢練㈣爾罐去執行測 忒,來發現程式中的問題點。 [〇11]根據本發明之一實施例一- j之種基於紅式運仃域之軟體 /、、- Π先轉-源程序之魏域,接著騎料進行分析, H、程序中取得與—變量有關的語句,以形成序; 根據專償源程序,以取得等價程序的運行域;最後比較源 之的功能域鱗價程序之的運行域是否重和合。 〃 [012]以上之關於本發明内容之說明及以下之實施方式之說 明係用以tf減轉本發明之精神與原理,並且提供本發明之專 利申晴範圍更進一步之解釋。 【實施方式】 []、下在只知方式中詳細敘述本發明之詳細特徵以及優 :、、八谷足、使任何热習相關技蟄者了解本發明之技術内容並 據以實施,且根據本_書所揭露之内容、_請專利顧及圖式, 任何^侧技#者可輕賊理解本發帅關之目的及優點。 [014]在開始说明本發明之前,先對本發明所使用的術語作一 簡介與說明。 [015]每個权體產品或項目都定義有非常詳盡的規格書 (specmcation) ^ t 200828011 範圍,在源程序(source eode)中也會對每個相關參數聲明其具 體的類支了稱之為功能域。各個程式執行時都有其運行的覆蓋 範圍,可稱之為運行域。 與’]規格書是對軟體輸入、輸出的定義,而軟體程式則說明 =現_的料法和數據結構。軸__定了輸入變量的 現树也定義了其找域。'魏在需求 的。,而在開姊獅中是由斯域來描述 ^錢的功能是定義在輸入空間的_個所謂功能域 血運==椒請扇的i顧。如果功能域 出^域不拉全重合,那麼軟體的故障或錯誤(㈣)就可檢測 _]基於規範的功能測試和基於程式的結構測試是兩類常 用的軟體測試方法。功能測試根據規格說明書設計測試範例,檢 ,程式的每—功能是否按照規範的要求正確地執行。它以軟體規 犯為依據碰觀㈣,其正雜依賴於規範的正雜。透過功 (能域與程式運行域的不同縫,可選擇有代表性_試數據以對 私式進行職,以大量節擇測試數據的時間。 [〇18]接著請參考『第1圖1洛 式運行域讀_財法之主錢崎縣之基於程 p 雜序:的魏域(㈣⑽),接㈣源程序 200),其主要β ^有關的語句’形成等價程序P,(步驟 無關的語句及函數。^ 態程序並剔除與輸入變量 接者’根據料、程序P,,以取得等價程序P, 200828011 的運行域(步驟300)。 [020]最後比較源程序P的魏域解價程序p,的運行域(步 驟4〇0)是否重合,以得到比較結果。如果功能域與運行域不能 70全重合’那麼权體的故障或錯誤(bug)就可檢測出來。 剛續請參考『第2圖』,鱗示m中取得源程序 P的功能域的流程圖。 自級入源程序p之語句(步驟ιοί),接著% 源程序ρ之函數’錢判斷讀人之語句是否為函數(步驟10Γ) 若不是函數,則繼續讀入源程序ρ(步驟1〇1)。如 j 源程序p為函數,則建立函數參數表(步驟ι〇3) 用表(步驟104)、變量表t 罨立函數§ 步雜至而步驟107相以j、w複合語句表(步驟106) 至步謂峨立二:,”繩;而步驟10 mum« 析所需的源程序的各〇 束,則繼續建立複合語句表(步若未衾 源程序P是否讀取結束(步_),_^ =則判處 ⑽),若未結束,則回到 ^ I。束(步觸 _胸參考『第 ^ ^源程序P。 P,的流程圖。 罘1圖』中取得源程序 [025]首先,將掃暗步 以取得-個變量(步驟lu j建立的變量表(步驟110), 驟II2)’並判斷所讀人之θ接著°胃人源轉1"的-行語句(步 驟113),若無闕,則繼⑴所取得之變量有關(步 认軸序?的語句,若«,則記錄 200828011 至源程序p,中。200828011 IX. Description of the invention: [Technical field to which the invention pertains] In particular, a program-based operation [0 01] The present invention relates to a private test method for a test method domain. [Prior Art] The development of the liquidity of the Tao software body is a big link. The test type is used to classify the vehicle. CQnstruetiGn Testing, System Testing, and special testing (Speciai conformance testing is a front-end (four) position, and the main focus is on the functional test of the terminal. It is normal to perform the operation properly. _ Lin is a late-stage integration test, and the test is based on the user's point of view, that is, how the user of the outside world will use the product. As for the special test Yes, the tests performed need to take more time and manpower to complete. _] In terms of test mode, it can be divided into self-box (service (four) (10) mail) and black box test (BlackBoxTesting). The test direction is different, the white box test is (4) the program structure is the main, and the black box test is based on the program function. [004] White box test is also called structural test (Stmctural Testing), white box show N type There are two major levels: DataFlow Coverage and Control Flow Coverage. The data flow surface is the test data that passes through the system. Process, control flow surface is the process of each stage of the test program during the execution process. [005] When performing black box test, the tester does not need to have a deep enough understanding of the structure of the software, 200828011, the test is heavy Some people call it a functional test. In order to control the heart (10): so it is also necessary to follow the test case (Test Cases); ^ = the quality of people must be directly affected _ 戦 results. es Cases [006] The software project has different visual properties, product silk _ no sister, product product saki ^ ^ domain products can not be caused by the quality of the software product is difficult to guarantee perfect. For the item =: completeness, guide ^ T shell (three) In the case of small droughts or droughts, or in terms of quality requirements, the manual method can also achieve the expected results. However, the constant production of the four systems, the continuous increase of Wei, and the increase in requirements of the products of the same households Consider the adoption of the __ test method to adapt: two seeking. And _] the complexity of the software product 4 in the fortune wall product integration and delivery quality department just started testing, a large number of errors (bug) appeared, this process, Test Engineer, The supervisor, the supervisor, the heart, the manpower, the material and so on. _]- Generally speaking, the bugs generated in the initial test of the product accounted for 70-80% of the total bugs, so how to quickly and automatically Early detection of this bug, h the key to product quality, shorten the development test cycle and improve customer satisfaction [009] to test whether the software developed has bugs, you can take a variety of different measurement and reduction strategies. Which test strategy, design test plan is B, the most critical issue in the test phase. Before testing, it is necessary to select the test data from the program definition domain, which is the key to the success of the test. SUMMARY OF INVENTION The method of 200828011. Straight mainly to raise the program based on the domain analysis _ test data generator _ two-type functional domain and the test domain of the test domain automatically use the cutter type of a variable type of the source code, complete the corresponding type 2 power acquisition, Through the lion's own program to run the statement for analysis, touch the money to practice (four) cans to perform the test, to find the problem points in the program. [〇11] According to one embodiment of the present invention, a type of j-based software based on the red-type software domain, /, Π first-to-source program, then the riding analysis, H, the program obtains - Variable-related statements to form the order; According to the special-purpose source program, to obtain the running domain of the equivalent program; finally, compare the running domain of the functional domain scalar program of the source. The above description of the present invention and the following description of the embodiments of the present invention are intended to provide a further explanation of the scope of the invention. [Embodiment] [], the detailed features of the present invention will be described in detail in the only known manner, and the advantages of the present invention will be described in detail, and the technical content of the present invention will be understood and implemented according to the present invention. _ The contents disclosed in the book, _ please patents take into account the pattern, any ^ side technology # can be light thief to understand the purpose and advantages of this hair. [014] Before beginning the description of the present invention, the terms used in the present invention will be briefly described and illustrated. [015] Each of the rights products or projects is defined by a very detailed specification (tm 200828011), and the source class (source eode) also declares its specific class for each relevant parameter. For the functional domain. Each program has its own coverage when it is executed, which can be called a running domain. The '] specification is a definition of software input and output, while the software program explains the current method and data structure. The current tree in which the axis __ defines the input variable also defines its domain. 'Wei is in demand. In the opening lion is described by the domain of the domain. The function of money is defined in the input space _ a so-called functional domain blood supply == pepper please fan i. Software faults or errors ((4)) can be detected if the functional domain is not fully overlapped. _] Specification-based functional testing and program-based structural testing are two common types of software testing methods. The functional test is designed according to the specification specification, and the test, each function of the program is correctly executed according to the requirements of the specification. It is based on software discipline (4), which is dependent on the norms of the norm. Through the different sews of the energy domain and the program running domain, you can choose a representative _ test data to perform the job in private mode, and to test the data in a large amount of time. [〇18] Then please refer to "1 Figure 1 Luo" The type of running domain read _ the main method of money law in the case of Qianqi County based on the process p. The sequence: the Wei domain ((four) (10)), then (four) source program 200), its main β ^ related statement 'forms the equivalent program P, (step-independent The statement and function of the state program and cull with the input variable 'according to the material, program P, to obtain the equivalent field P, 200828011 run field (step 300). [020] Finally compare the source field of the source program P Whether the running domain (step 4〇0) of the pricing program p, coincides to obtain the comparison result. If the functional domain and the running domain cannot be fully coincident, then the fault or bug of the right body can be detected. Please refer to "Fig. 2", the flowchart showing the function domain of the source program P in m. The statement of the self-level source program p (step ιοί), followed by the function of the % source program ρ 'money judgment reader's statement Whether it is a function (step 10Γ) If it is not a function, continue to read the source program ρ (step 1〇1). If the j source program p is a function, then the function parameter table is created (step ι〇3) using the table (step 104), the variable table t 罨 the function § step is mixed, and the step 107 is combined with j, w Statement table (step 106) to step is said to stand two:, "rope; and step 10 mum« analysis of the various end of the source program, then continue to build a compound statement table (step if the source program P is not read End (step _), _^ = then judge (10)), if not finished, return to ^ I. bundle (step _ chest reference "the ^ ^ source program P. P, the flow chart. 罘 1 map" Obtaining the source program [025] First, the dark step is taken to obtain a variable (the variable table established in step lu j (step 110), step II2) 'and judge the θ of the read person and then the stomach source turns 1" - Line statement (step 113), if there is no flaw, it is related to the variable obtained by (1) (the statement of step recognition axis sequence, if «, record 200828011 to source program p, medium.
若未讀取完畢, 則繼續取得T -個後f複上述的步驟 115 )’若未結 。若讀取結束,則判斷變 。若讀取完畢,則結束, 步驟115。 111至 依據輸入空間的範圍進行選擇劃分。 [027]如果函數中有-些表達式及其他—些數學函數,則應該 _]-般而言’輸人空間可關分為四部份,即:时川 E2UE3UE4,其中: [029] El={x |x£DfflDp} [030] Ε2={χ |χ^η DfRDp} [031] Ε3={χ |xeDfnnDp} [032] Ε4={χ |χΕ] Dfn~i Dp} [033] Df表示輸入變量的功能域,Dp表示運行域。 [034] E1表示規範與程序有相同的輸入子域,但實現與說明 是否一致,還需進一步測試。 [035] E2表明程序產生了一個結果,但規範並沒有要求1對 於這種情況,可補充規範或者縮小其程序的運行域。 [036] E3表明規範的某些要求,程序沒有處裡。 [037] E4關於例外處理,即規範既未要求,程序也無從處理 對於規範未指明的輸入’程序可能產生不可預料的結果。因此, 在可靠的軟體程式中,例外處理為必要之程序。 10 200828011 、陶根據以上之酬書,_序p以文件形式私,再建立 關;原私序p的各種變量紀錄,並依據紀錄提供的信扈、,從源程 =程中嫌量的靜態 貝王 ,y後確定輸入變量的運行域。 陶下面將對本發明進行舉例說明,首先給出源程序卜由 |nam(),xpomt〇,f〇,p〇wer〇組成,其輪入變量為 X, [040]給定一源程序p如下: 、'、If the reading is not completed, continue to obtain T - and then repeat the above steps 115) if not closed. If the reading is completed, the judgment is changed. If the reading is completed, the process ends, step 115. 111 to Select the division according to the range of the input space. [027] If there are some expressions and other mathematical functions in the function, then _]-likely, the input space can be divided into four parts, namely: Shichuan E2UE3UE4, where: [029] El ={x |x£DfflDp} [030] Ε2={χ |χ^η DfRDp} [031] Ε3={χ |xeDfnnDp} [032] Ε4={χ |χΕ] Dfn~i Dp} [033] Df Indicates the functional domain of the input variable, and Dp represents the running domain. [034] E1 indicates that the specification has the same input subfield as the program, but the implementation is consistent with the description and further testing is required. [035] E2 indicates that the program produced a result, but the specification does not require 1 for this case, supplementing the specification or narrowing the operating domain of its program. [036] E3 indicates certain requirements of the specification, and the procedure is not in place. [037] E4 on exception handling, ie neither the specification nor the procedure is processed. The procedure for an input that is not specified by the specification may produce unpredictable results. Therefore, in a reliable software program, exception handling is a necessary procedure. 10 200828011, Tao according to the above rewards, _ order p in the form of documents private, and then establish the customs; the original private order p of various variable records, and according to the letter provided by the record, from the source = the static amount of the process Bewang, after y, determine the running domain of the input variable. Tao will exemplify the present invention. First, the source program is composed of |nam(), xpomt〇, f〇, p〇wer〇, and its rounding variable is X, [040] given a source program p is as follows : , ',
intp〇wer(intX,inti) { intp; f〇r(p=l; i>〇; -i) P = P*x; retum(p); } float f(float x) { float y; y = ((χ_0·5)*χ+16·0)*χ - 80·〇; retum(y); } float xpoint(float xl) { float y; y=xl *f(xl)/(f(xl+1.0) - f(3.453))· retum(y); 11 200828011Intp〇wer(intX,inti) { intp; f〇r(p=l; i>〇; -i) P = P*x; retum(p); } float f(float x) { float y; y = ((χ_0·5)*χ+16·0)*χ - 80·〇; retum(y); } float xpoint(float xl) { float y; y=xl *f(xl)/(f(xl+ 1.0) - f(3.453))· retum(y); 11 200828011
void mainQ { int k; float x ? y; printf(7n-----Print the value of function power-----/n”); for(k=0;k<l 0;k++) printf(n%d%d%d \nn,k,power(2,k) ’ power(-3,k)); printf(7n-----Print the value of function xpoint-----/n”);Void mainQ { int k; float x ? y; printf(7n-----Print the value of function power-----/n"); for(k=0;k<l 0;k++) printf( N%d%d%d \nn,k,power(2,k) ' power(-3,k)); printf(7n-----Print the value of function xpoint-----/n) );
Scan(,,%r,&x}; while(x>0) { y=xpoint(x); ,x,y); scanf(f!%f! 5 &x); } } [041]基於輸入變量對上述之源程序p分析,以得到一 序,如下: 1貝程 float f(float x) { float y; y=((x-0.5)*x+16.0)*x-80.0; retum(y); float xpoint(float xl) 12 200828011 float y; y=xl * f(xl) / (f(xl+1.0>f(3.453)); retum(y); } void main() { float x,y; scan(’’%r,&x); while(x>〇) { y^xpoin^x); printf(ff%f%f! 5 x ^ y);Scan(,,%r,&x};while(x>0) { y=xpoint(x); ,x,y); scanf(f!%f! 5 &x); } } [041] The above-mentioned source program p is analyzed based on the input variables to obtain a sequence as follows: 1 Bayer float f(float x) { float y; y=((x-0.5)*x+16.0)*x-80.0; retum (y); float xpoint(float xl) 12 200828011 float y; y=xl * f(xl) / (f(xl+1.0>f(3.453));retum(y); } void main() { float x,y; scan(''%r,&x);while(x>〇) { y^xpoin^x); printf(ff%f%f! 5 x ^ y);
Scanf(ff%f! ? &x); } , [〇42]根據本發明所減<方法,首先取得紀錄程式中的變 量,此程式變量列表中只有變量义、^、]^。 接著針對變量x的程式分析,得到等價程序p,,等價p, 中去掉了與輸人變量x無關的變量。k及其相關語句與函數 POWER() P中變量與函數都與輸入變量χ有關,並且與p二者 辛=專彳貝口此,P與P的運行域一致。但是,p,只分析與輸 入k里有關的部份,有利於程式運行域的確定。 [044]接著分析p’以確定運行域。對函數進行分析,例如對 P ·、0進行刀析,其變量為χι,類型為丘〇at,打〇泔型變量,其功 此域疋義為卜3.4028235E38,3.4028235E38]同時函數中,其表達 13 200828011 式中分母不能為G ’則可得xl内容不能f於2·453,如此綜合參 考其功能域及運行域範圍,可得其可執行域範圍, [-3·402δ235Ε38,-1],卜1,〇],[〇,1],[1,2.453),(2.453, 3.4028235Ε38] ’職其絲是否核。轉如上—些特殊值等去 測試其結果,如此可不需每個變量值均去執行一遍,從 量時間。 '' 、[〇45]本發明係一種基於程式運行域分析的測試數據生成方 法三其主要提出了-種基於程式功能域與運行域的測試數據自動 確定方,其通過分析每-個應用於原程式的變量類型,完 用程式功能域的獲取,透過對應用程式本身運行語句進 了 運行域’通過此法獲取有代表性的測試數據去執行測 忒’來發現程式中的問題點。 、 [〇46]雖穌發明以前述之實施觸露如上,㈣ 定本發明。在不雌本發明之精彻 更 、 均屬太由, 国門所為之更動與潤飾, δ月之專利保護範圍。關於本發明所界 考所附之申請專利範圍。 更耗圍叫參 【圖式簡單說明】 =,係為第1圖中取得源程序p的功能域的流程圖。 ® ’躺弟1®中取得馳序p,的流程圖。 【主要7L件符號說明】 無 14Scanf(ff%f! ? &x); } , [〇42] According to the subtractive method of the present invention, the variables in the record program are first obtained, and only the variable meanings, ^, ]^ are included in the list of program variables. Then, for the program analysis of the variable x, the equivalent program p, the equivalent p, is removed, and the variable unrelated to the input variable x is removed. k and its related statements and functions POWER () P variables and functions are related to the input variable ,, and with p 辛 = special Beikou this, P and P run field consistent. However, p only analyzes the part related to the input k, which is beneficial to the determination of the program running domain. [044] Next p' is analyzed to determine the run domain. Analyze the function, for example, the knife analysis of P ·, 0, the variable is χι, the type is 〇 〇 at, the snoring type variable, the function of this domain is 3.4 3.4028235E38, 3.4028235E38] in the simultaneous function, Its expression 13 200828011 where the denominator can not be G 'can obtain xl content can not f at 2.453, so comprehensive reference to its functional domain and operating domain range, can get its executable domain range, [-3·402δ235Ε38,-1 ], Bu 1, 〇], [〇, 1], [1, 2.453), (2.453, 3.4028235Ε38] 'Whether the wire is nuclear. Turn to the above - some special values to test the results, so do not need each The variable values are all executed once, and the time is from the time. '', [〇45] The present invention is a method for generating test data based on program running domain analysis. The main method is to automatically test data based on the program function domain and the running domain. Determining the party, by analyzing each variable type applied to the original program, completing the acquisition of the program function domain, and running the statement into the running domain by running the statement on the application itself to obtain representative test data to perform the test.忒 'to find the program The problem is. [〇46] Although the invention was exposed as described above, (4) The invention was established. In the absence of the invention, the invention is more sophisticated and more versatile, and the national gate is more dynamic and retouching, δ月之之Scope of patent protection. Regarding the scope of the patent application attached to the scope of the invention, it is a flowchart of the functional domain of the source program p in Fig. 1. Flowchart for obtaining the sequence p in the brother 1®. [Main 7L symbol description] No 14