オブジェクトのリッチな比較: 同一クラスの別インスタンス同士(MorePowerAssertSpec)
Condition not satisfied:
obj1.p() == obj2.p()
| | | | |
| | | | [value:ほけ, class:class MorePowerAssertSpec$Hoge, name:あいえお]
| | | MorePowerAssertSpec$Hoge@5b2f13ef
| | false
| | 2 differences (98% similarity)
| | [value:ほ(げ), class:class MorePowerAssertSpec$Hoge, name:あい(う)えお]
| | [value:ほ(け), class:class MorePowerAssertSpec$Hoge, name:あい(-)えお]
| [value:ほげ, class:class MorePowerAssertSpec$Hoge, name:あいうえお]
MorePowerAssertSpec$Hoge@518c7084
at MorePowerAssertSpec.groovy:44)
|Running 4 spock tests... 3 of 4
--Output from オブジェクトのリッチな比較: 別クラス同士--
オブジェクトのリッチな比較: 別クラス同士(MorePowerAssertSpec)
Condition not satisfied:
obj1.p() == obj2.p()
| | | | |
| | | | [value:ほけ, class:class MorePowerAssertSpec$Hoge, name:あいえお]
| | | MorePowerAssertSpec$Hoge@7a053e2d
| | false
| | 2 differences (98% similarity)
| | [value:ほ(げ), class:class MorePowerAssertSpec$Hoge, name:あい(う)えお]
| | [value:ほ(け), class:class MorePowerAssertSpec$Hoge, name:あい(-)えお]
| [value:ほげ, class:class MorePowerAssertSpec$Hoge, name:あいうえお]
MorePowerAssertSpec$Hoge@28c08f61
at MorePowerAssertSpec.groovy:50)
Last active
December 24, 2015 11:19
-
-
Save nobeans/6790221 to your computer and use it in GitHub Desktop.
bleisさんの「そろそろPower Assertについてひとこと言っておくか」に纏わるお試しコード
http://bleis-tift.hatenablog.com/entry/about-power-assert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import spock.lang.Specification | |
class MorePowerAssertSpec extends Specification { | |
def obj1 = new Hoge(name: "あいうえお", value: "ほげ") | |
def obj2 = new Hoge(name: "あいえお", value: "ほけ") | |
def obj3 = new Foo(name: "あいうえお", value: "ほげふう", extra: "ふう") | |
def setup() { | |
Object.metaClass.p = { delegate.properties.toString() } | |
} | |
void "オブジェクトのリッチな比較: 同一インスタンス同士"() { | |
expect: | |
obj1.p() == obj1.p() | |
obj2.p() == obj2.p() | |
obj3.p() == obj3.p() | |
} | |
void "オブジェクトのリッチな比較: 同一クラスの別インスタンス同士"() { | |
expect: | |
obj1.p() == obj2.p() | |
} | |
void "オブジェクトのリッチな比較: 別クラス同士"() { | |
expect: | |
obj1.p() == obj2.p() | |
} | |
class Hoge { | |
def name | |
def value | |
} | |
class Foo { | |
def name | |
def value | |
def extra | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ちょっとclassがウザいけど、こんな感じかしら