Skip to Main Content
Mathematica 錦囊妙計
book

Mathematica 錦囊妙計

by Sal Mangano
April 2014
Beginner to intermediate content levelBeginner to intermediate
830 pages
15h 21m
Chinese
GoTop Information, Inc.
Content preview from Mathematica 錦囊妙計
764
|
第十九章
討論說明
使用
Test
指令的
EquivalenceFunction
選項可建立更具彈性的測試案例,它可以用來指
定通過測試的條件。以下測試案例中,只要實際輸出結果大於 0 便通過測試。[Page-766]
ch19.indd 764 2014/4/2 下午 05:10:50
19.10 使用 MUnit 組織並控制測試群組
|
765
此選項於比對條件沒有這麼精確的情況下很好用。例如,你可能會想使用
Round
Chop
指令於程式輸出結果。[Page-767]
當然,你可以在撰寫程式時便把
Chop
指令寫進程式碼,但我認為
EquivalenceFunction
比較符合程式設計師的需求。以下提供另一個範例,判斷程式輸出結果是否在錯誤容忍
值之內。
19.10 使用 MUnit 組織並控制測試群組
問題點
你有一個複雜的測試案例集,其中可細分為數個群組,你希望能取決於其餘群組的測試
結果,而進一步開啟或關閉某測試群組,這也許是為了測試某些副作用。例如,或許只
有在條件成立時才進行某測試群組,因為後續的測試需用到先前的測試結果。
解決方案
MUnit
有些進階功能可用來組織測試群組並處理測試群組間的相關性,你可以把數個測
BeginTestSection[name,switch] ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Ubuntu for Non-Geeks, 4th Edition

Ubuntu for Non-Geeks, 4th Edition

Rickford Grant, Phil Bull

Publisher Resources

ISBN: 9789863470106