첫 번째 플레이어가 이길 때 테스트 빌드

선택한 항목이 가장 강력할 때 첫 번째 플레이어가 승리합니다.
  • 첫 번째 플레이어가 가위를 선택하고 두 번째 플레이어가 종이를 선택한 경우:

  • 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]
    링크드인:
    트위터:

    좋은 웹페이지 즐겨찾기