0

ダイアログ ボックスなどのプレーンな Java Swing コンポーネントを作成する場合、ダイアログを表示するための単体テストを作成するのは非常に簡単です。基本的には、ダイアログのインスタンスを作成して setIsVisible(true) を呼び出すだけです。グリフォンビューでこれを行う方法を理解するのに本当に苦労しています。統合テストでこれを実行しようとしましたが、取得できないようです。

ビューを表示するためにいくつかのことを試しましたが、何も機能していないようです。ビューのインスタンスを取得できると思われる唯一の方法は次のとおりです。 AirplaneView view = helper.newInstance(app, griffonpractice.AirplaneView.class, "Airplane")

この後、私はできるかもしれないと思ったview.setIsVisible(true) or view.frame.setIsVisible(true)が、運がなかった。私はこれについて間違った方法で考えていると思います.これを行うにはかなり簡単な方法が必要です. どんな助けでも大歓迎です。私のビューは次のようになります。バインディングがないため、何もモックする必要がないことに注意してください。

package griffonpractice
import javax.swing.JFrame

JFrame frame = application(title: 'GriffonPractice',
  size: [320,480],
  pack: true,
  location: [50,50],
  locationByPlatform:true){
    borderLayout()
    {
        hbox(constraints: BL.NORTH)
        {
            label(text: "shane")
            label(text: "Jack");
        }
    }
}
4

1 に答える 1

0

FESTを使ってみましたか?http://easytesting.org

Griffon in Actionには、FEST を使用した Griffon アプリケーションのテストに関する詳細な例が記載されています。ソース コードはhttp://code.google.com/p/griffoninaction/source/browse/trunk/chap09/dictionaryで入手できます。

簡単なアプリケーションの 3 つのテストの短い例を次に示します。

package dictionary

import org.fest.swing.fixture.*
import griffon.fest.FestSwingTestCase

class DictionaryTests extends FestSwingTestCase {
    void testInitialState() {
        window.button('search').requireDisabled()
    }

    void testWordIsFound() {
        window.with {
            textBox('word').enterText('griffon')
            button('search').click()
            textBox('result')
                .requireText('griffon: Grails inspired desktop application development platform.')
        }
    }

    void testWordIsNotFound() {
        window.with {
            textBox('word').enterText('spock')
            button('search').click()
            textBox('result')
                .requireText("spock: Word doesn't exist in dictionary")
        }
    }

    protected void onTearDown() {
        app.models.dictionary.with {
            word = ""
            result = ""
        }
    }
}
于 2010-10-12T22:41:45.327 に答える