Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第19章 前準備 #24

Merged
merged 4 commits into from
Jan 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
18 changes: 14 additions & 4 deletions part02/src/xunit.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@ 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.was_run.should eq false
test.run
test.was_run.should eq true
@test.run
@test.was_run.should eq true
end

def test_setup
@test.run
@test.was_setup.should eq true
end
end

TestCaseTest.new("test_running").run
TestCaseTest.new("test_setup").run
4 changes: 4 additions & 0 deletions part02/src/xunit/test_case.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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) %}
Expand Down
5 changes: 5 additions & 0 deletions part02/src/xunit/was_run.cr
Original file line number Diff line number Diff line change
@@ -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
Expand Down