0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Mockの使い方

Posted at

クラスの宣言

まずMockさせるクラスをフィールドとして宣言する。

@Mocked
Hoge hoge;

Mockの条件

対象のメソッドの中にMockの条件を記したメソッドを以下のように書く。

new NonStrinctExpectations(){
    {
        hoge.hogehoge();
        result = aaa;
    }
};

これで、hogeクラスのhogehogeメソッドを実行すると、aaaという結果が返ってくるよう設定ができる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?