軟體規格在軟體開發中占了一個舉足輕重的角色,軟體規格除了用來精確地定義一個軟體所該擁有的性質與行為外,更是開發人員之間或是開發人員與客戶之間的溝通媒介。本論文描述一個可以自動化的將原本不可執行的類別圖與物件限制語言規格轉換成可執行的限制邏輯程式規格的轉換器的設計與實作。這個自動轉換需要解決兩個主要問題。第一個問題是如何產生符合類別圖關聯關係中類別實例數量限制的物件。第二個問題是如何產生符合物件限制語言中類別恆定條件、函式前置條件、及函式後置條件的物件。限制邏輯程式的一致化機制和強大的解限制能力使得產生可執行規格的問題變得容易許多。產生出來的可執行限制邏輯程式規格可以應用在黑箱測試中做為測試案例產生器,同時產生測試輸入及預期輸出,或應用在白箱測試中做為預期輸出產生器,產生預期輸出。
Software specification plays an important role in software development. It precisely defines all properties and behaviors of the software to be developed, and plays the role of communication medium between developers and customers. This thesis describes the design and implementation of a converter which can automatically convert a non-executable class diagram with Object Constraint Language (OCL) specification to an executable Constraint Logic Programming (CLP) specification. There are two major problems in this automatic conversion: the first is to create objects that conform to the cardinality constraints of the association relations defined in the class diagram. The second is to create objects that conform to the class invariants, method preconditions, and method postconditions defined in OCL. The general unification mechanism and the powerful constraint solving capability of CLP makes this automatic conversion much easier. The executable CLP specification can be used as a test case generator to generate both test input and expected output in black-box testing, or as a test oracle to generate expected output in white-box testing.