첫 번째 플레이어가 이길 때 테스트 빌드
9181 단어 tutorialwebdevelixiralgorithms
defmodule GameTest do
use ExUnit.Case
@stone 1
@paper 2
@scissor 3
# ...
describe "Game.play/2 when first player wins" do
test "when first player chooses scissor and second player chooses paper" do
first_player_choice = @scissor
second_player_choise = @paper
assert {:ok, match} = Game.play(first_player_choice, second_player_choise)
assert match == "First player win!!!"
end
end
end
defmodule GameTest do
use ExUnit.Case
@stone 1
@paper 2
@scissor 3
# ...
describe "Game.play/2 when first player wins" do
# ...
test "when first player chooses paper and second player chooses stone" do
first_player_choice = @paper
second_player_choise = @stone
assert {:ok, match} = Game.play(first_player_choice, second_player_choise)
assert match == "First player win!!!"
end
end
end
defmodule GameTest do
use ExUnit.Case
@stone 1
@paper 2
@scissor 3
# ...
describe "Game.play/2 when first player wins" do
# ...
test "when first player chooses stone and second player chooses scissor" do
first_player_choice = @stone
second_player_choise = @scissor
assert {:ok, match} = Game.play(first_player_choice, second_player_choise)
assert match == "First player win!!!"
end
end
end
Let's look at the code of the tests when the game's result is
"First player win!!!"
.
defmodule GameTest do
use ExUnit.Case
@stone 1
@paper 2
@scissor 3
# ...
describe "Game.play/2 when first player wins" do
test "when first player chooses scissor and second player chooses paper" do
first_player_choice = @scissor
second_player_choise = @paper
assert {:ok, match} = Game.play(first_player_choice, second_player_choise)
assert match == "First player win!!!"
end
test "when first player chooses paper and second player chooses stone" do
first_player_choice = @paper
second_player_choise = @stone
assert {:ok, match} = Game.play(first_player_choice, second_player_choise)
assert match == "First player win!!!"
end
test "when first player chooses stone and second player chooses scissor" do
first_player_choice = @stone
second_player_choise = @scissor
assert {:ok, match} = Game.play(first_player_choice, second_player_choise)
assert match == "First player win!!!"
end
end
end
다음 게시물에서는 첫 번째 플레이어가 승리할 때 테스트에 따라 모듈 게임을 코딩할 것입니다.
콘택트 렌즈
이메일: [email protected]
링크드인:
트위터:
Reference
이 문제에 관하여(첫 번째 플레이어가 이길 때 테스트 빌드), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/dnovais/building-the-tests-when-the-first-player-wins-1hd0텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)