TDD com 불로장생약

15210 단어 elixirtdd

불로장생의 약으로 자동 테스트 실행기(testes ques ão escritos como código)를 치료하는 데 쓰인다.
Com isso, voc弊pode fazer TDD(테스트 드라이브 개발) Com facilidade.Não sabe o queéTDD?레야오livro do Maurício Aniche!
어, 너 좋은 약 있어?

섹션 1: 프로젝트 진행


Uma vez tendo o o Elixir instalado, voc ben vai num 터미널(meu caso 없음, um Ubuntu 20.04 dentro do WSL do Windows 10 없음), e digita mix new .아니, 아니, 아니, 아니.
elixir@utfpr:~/DevTo$ mix new calculadora
* creating README.md
* creating .formatter.exs
* creating .gitignore
* creating mix.exs
* creating lib
* creating lib/calculadora.ex
* creating test
* creating test/test_helper.exs
* creating test/calculadora_test.exs

Your Mix project was created successfully.
You can use "mix" to compile it, test it, and more:

    cd calculadora
    mix test

Run "mix help" for more commands.
당장!O는 파스타와 파스타를 섞어 파스타 자유 테스트로 활용한다.좋아, 너는 스파게티와 테스트 스파게티를 함께 섞을 수 있어.엘름 디소 크리오 5번지.노스코에 관한 예는 성 아페나스의 자유/계산을 간소화시켰다.exe시험/calculadora 시험.전 남자친구.

Passo 2-Rodar os Testes


이것은 그림으로 위에'혼합설탕'이라고 쓰여 있는데 표지는'a criaço do projeto, vápara a pota do novo projeto,calculadora,e execute os testes'이다.Sim,o mix jácria testes para você.
Vamos primeiro então rodar os testes que o mix criou:
elixir@utfpr:~/DevTo$ cd calculadora
elixir@utfpr:~/DevTo/calculadora$ mix test
Compiling 1 file (.ex)
Generated calculadora app
..

Finished in 0.08 seconds
1 doctest, 1 test, 0 failures

Randomized with seed 652059
elixir@utfpr:~/DevTo/calculadora$
오르하. - 규. - 법!테스트 통과!네, 똑딱dois testes: 네, 의사 테스트, 응, 고환이 정상이에요.

Passo 3: 의사 테스트 제거기


너는 우리를 함께 가게 하고 싶니?중요: estou usando Elixir 1.11.2사람마다 다른 내용이 있다.
알키보 리브/가르콜라도라.전임:
defmodule Calculadora do
  @moduledoc """
  Documentation for `Calculadora`.
  """

  @doc """
  Hello world.

  ## Examples

      iex> Calculadora.hello()
      :world

  """
  def hello do
    :world
  end
end

너는 의사, 너는 의사, 너는 의사, 너는 의사라고 말할 수 있다.
알키보 리브/가르콜라도라.ex passa a ser:
defmodule Calculadora do
  @moduledoc """
  Documentation for `Calculadora`.
  """

  def hello do
    :world
  end
end

Rodemos os testes de novo:
elixir@utfpr:~/DevTo/calculadora$ mix test
Compiling 1 file (.ex)
.

Finished in 0.03 seconds
1 test, 0 failures

Randomized with seed 900374
elixir@utfpr:~/DevTo/calculadora$
당장!Agora sótemos um teste.

네 번째 관문: 에스리빌 오세 프리메로 트레


와모스 다르 우마 오르하다는 테스트가 없나?Estáem 시험/calculadora 시험.전 남자친구.
이거 너무 중요해!O arquivo-deve-estar-na 분식 테스트/e seu-nome-deve-terminar-em 테스트.전 남자친구.아힘에게 아쿠보 콘틴도 오스 테레스(arquivo contendo os testes)와 바이 와이(vai ser encontrado pela biblioteca que roda os testes)는 책이다.
Arquivo 시험/calculadora 시험.exs:
defmodule CalculadoraTest do
  use ExUnit.Case
  doctest Calculadora

  test "greets the world" do
    assert Calculadora.hello() == :world
  end
end
코모 비모스 아시마(Como vemos acima, o teste gerado pelo mix)는'세계에 인사'(traduço:'cumprimenta o mundo')를 묘사했다.
Oúnico comando deste testeéum assert.이것은 구글이 번역한 언어이다. 컴퓨터에 대한 흥미를 표현할 수도 있고, 세계에 대한 견해를 표현할 수도 있다.
O 테스트 2+2=4 시 간단도:
  test "2+2 é 4" do
    assert Calculadora.soma(2,2) == 4
  end
테스트 테스트, 알쿠보 테스트/calculadora 테스트.exs passa a ser:
defmodule CalculadoraTest do
  use ExUnit.Case
  doctest Calculadora

  test "greets the world" do
    assert Calculadora.hello() == :world
  end

  test "2+2 é 4" do
    assert Calculadora.soma(2,2) == 4
  end
end
테스트 과정에서 우리는 재미있는 계산 과정이 필요하다.soma/2.
Rodemos os testes de novo:
elixir@utfpr:~/DevTo/calculadora$ mix test
warning: Calculadora.soma/2 is undefined or private
  test/calculadora_test.exs:10: CalculadoraTest."test 2+2 é 4"/1

.

  1) test 2+2 é 4 (CalculadoraTest)
     test/calculadora_test.exs:9
     ** (UndefinedFunctionError) function Calculadora.soma/2 is undefined or private
     code: assert Calculadora.soma(2,2) == 4
     stacktrace:
       (calculadora 0.1.0) Calculadora.soma(2, 2)
       test/calculadora_test.exs:10: (test)



Finished in 0.3 seconds
2 tests, 1 failure

elixir@utfpr:~/DevTo/calculadora$
파하람 고환?Ótimo.에스페라도 시대.

5단: 파제 오테트 파사르 우산도 파소스 데베베.


베이비 스텝(Baby Steps)은 테스트할 필요가 없는 방법이다.Neste caso,o mínimo necessárioéescrever a funço Calculadora.소마/2 이그노란도 슈스 파리 지하철역 4번:
  def soma(_,_), do: 4
알키보 리브/가르콜라도라.ex passa a ser:
defmodule Calculadora do
  @moduledoc """
  Documentation for `Calculadora`.
  """

  def hello do
    :world
  end

  def soma(_,_), do: 4
end
Rodemos os testes de novo:
elixir@utfpr:~/DevTo/calculadora$ mix test
Compiling 1 file (.ex)
..

Finished in 0.03 seconds
2 tests, 0 failures

Randomized with seed 371832
elixir@utfpr:~/DevTo/calculadora$ 

제6관문: 에스리빌과 세공도


O는 3+3=6 시 테스트를 수행합니다.
  test "3+3 é 6" do
    assert Calculadora.soma(3,3) == 6
  end
테스트 테스트, 알쿠보 테스트/calculadora 테스트.exs passa a ser:
defmodule CalculadoraTest do
  use ExUnit.Case
  doctest Calculadora

  test "greets the world" do
    assert Calculadora.hello() == :world
  end

  test "2+2 é 4" do
    assert Calculadora.soma(2,2) == 4
  end

  test "3+3 é 6" do
    assert Calculadora.soma(3,3) == 6
  end
end
Rodemos os testes de novo:
elixir@utfpr:~/DevTo/calculadora$ mix test
..

  1) test 3+3 é 6 (CalculadoraTest)
     test/calculadora_test.exs:13
     Assertion with == failed
     code:  assert Calculadora.soma(3, 3) == 6
     left:  4
     right: 6
     stacktrace:
       test/calculadora_test.exs:14: (test)



Finished in 0.06 seconds
3 tests, 1 failure

Randomized with seed 966924
elixir@utfpr:~/DevTo/calculadora$
이것은 다른 책략이다.오스터 에스페라바는 재미있는 사람이야.
당신은 파제르입니까, 아니면 파사르입니까?
아그라 바스타(Agora basta implementar de fato a funço Calculadora).soma/2:
  def soma(num1, num2), do: num1 + num2
알키보 리브/가르콜라도라.ex passa a ser:
defmodule Calculadora do
  @moduledoc """
  Documentation for `Calculadora`.
  """

  def hello do
    :world
  end

  def soma(num1, num2), do: num1 + num2
end
Rodemos os testes de novo:
elixir@utfpr:~/DevTo/calculadora$ mix test
Compiling 1 file (.ex)
...

Finished in 0.03 seconds
3 tests, 0 failures

Randomized with seed 498106
elixir@utfpr:~/DevTo/calculadora$
테스트 통과!
네, 아조 규폴 호제 소소.Daqui vocês jápodem continuar.
아펠마르/우사도 주유소ExUnit와 장생불로약 테스트 기구(arcabouço)의 재설계 과정에서 우리는 줄곧 노력해 왔다.
당신의 검이 불로장생의 약이라는 말입니까?

부언: 응, 비디오 레라시오나도

좋은 웹페이지 즐겨찾기