From 900cba755b09e977be1504b187d7a46ca86fe78d Mon Sep 17 00:00:00 2001 From: at-grandpa Date: Tue, 9 Jan 2018 19:07:29 +0900 Subject: [PATCH 1/4] first commit --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 1edcca0..ce142e5 100644 --- a/README.md +++ b/README.md @@ -28,3 +28,4 @@ * [第Ⅰ部 個人的な感想](https://github.com/at-grandpa/study-tdd/issues/22) * 第Ⅱ部 xUnit * [第18章 xUnit へ向かう小さな一歩](https://github.com/at-grandpa/study-tdd/pull/23) + * [第19章 前準備](https://github.com/at-grandpa/study-tdd/pull/24) From 5570506481f9ebab28e36f91fbec6e819c697051 Mon Sep 17 00:00:00 2001 From: at-grandpa Date: Tue, 9 Jan 2018 20:59:35 +0900 Subject: [PATCH 2/4] =?UTF-8?q?setup=E3=81=AE=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- part02/src/xunit.cr | 8 ++++++++ part02/src/xunit/test_case.cr | 4 ++++ part02/src/xunit/was_run.cr | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/part02/src/xunit.cr b/part02/src/xunit.cr index dde8a50..5f6c65d 100644 --- a/part02/src/xunit.cr +++ b/part02/src/xunit.cr @@ -10,6 +10,14 @@ class TestCaseTest < TestCase test.run test.was_run.should eq true end + + def test_setup + # runをしたらsetupが呼ばれていることを検証している + test = WasRun.new("test_method") + test.run + test.was_setup.should eq true + end end TestCaseTest.new("test_running").run +TestCaseTest.new("test_setup").run diff --git a/part02/src/xunit/test_case.cr b/part02/src/xunit/test_case.cr index a19b884..30a9a52 100644 --- a/part02/src/xunit/test_case.cr +++ b/part02/src/xunit/test_case.cr @@ -2,7 +2,11 @@ class TestCase def initialize(@name : String) end + def setup + end + def run + setup {% begin %} case @name {% for method, index in @type.methods.map(&.name) %} diff --git a/part02/src/xunit/was_run.cr b/part02/src/xunit/was_run.cr index 8c77ee2..ed87489 100644 --- a/part02/src/xunit/was_run.cr +++ b/part02/src/xunit/was_run.cr @@ -1,5 +1,10 @@ class WasRun < TestCase getter was_run : Bool = false + getter was_setup : Bool = false + + def setup + @was_setup = true + end def test_method @was_run = true From ec7ee50588a3faa3b7f3fb82af487281daaa4976 Mon Sep 17 00:00:00 2001 From: at-grandpa Date: Tue, 9 Jan 2018 21:03:11 +0900 Subject: [PATCH 3/4] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=81=8C?= =?UTF-8?q?=E5=8B=95=E3=81=84=E3=81=A6=E3=81=84=E3=82=8B=E3=81=93=E3=81=A8?= =?UTF-8?q?=E3=82=92=E7=A2=BA=E8=AA=8D=E3=81=97=E3=81=A4=E3=81=A4=E3=80=81?= =?UTF-8?q?=E3=82=B7=E3=83=B3=E3=83=97=E3=83=AB=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- part02/src/xunit.cr | 1 - 1 file changed, 1 deletion(-) diff --git a/part02/src/xunit.cr b/part02/src/xunit.cr index 5f6c65d..6a2bdb7 100644 --- a/part02/src/xunit.cr +++ b/part02/src/xunit.cr @@ -6,7 +6,6 @@ require "spec/dsl" class TestCaseTest < TestCase def test_running test = WasRun.new("test_method") - test.was_run.should eq false test.run test.was_run.should eq true end From 18f4f42e0ad62b0e3200a669abe49898b5800186 Mon Sep 17 00:00:00 2001 From: at-grandpa Date: Tue, 9 Jan 2018 21:36:05 +0900 Subject: [PATCH 4/4] =?UTF-8?q?setup=E3=82=92=E4=BD=BF=E7=94=A8=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- part02/src/xunit.cr | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/part02/src/xunit.cr b/part02/src/xunit.cr index 6a2bdb7..bf69ece 100644 --- a/part02/src/xunit.cr +++ b/part02/src/xunit.cr @@ -4,17 +4,20 @@ require "spec/methods" require "spec/dsl" class TestCaseTest < TestCase + @test : WasRun = WasRun.new("") + + def setup + @test = WasRun.new("test_method") + end + def test_running - test = WasRun.new("test_method") - test.run - test.was_run.should eq true + @test.run + @test.was_run.should eq true end def test_setup - # runをしたらsetupが呼ばれていることを検証している - test = WasRun.new("test_method") - test.run - test.was_setup.should eq true + @test.run + @test.was_setup.should eq true end end