(ExUnit.Duplicate Test Error) "test stores values by key"

this is my test

defmodule KV.BucketTest do
  use ExUnit.Case, async: true

  setup do
    {:ok, bucket} = KV.Bucket.start_link([])
    %{bucket: bucket}
  end

  test "stores values by key", %{bucket: bucket} do
    assert KV.Bucket.get(bucket, "milk") == nil
    KV.Bucket.put(bucket, "milk", 3)
    assert KV.Bucket.get(bucket, "milk") == 3
  end

  test "stores values by key", %{bucket: bucket} do
    assert KV.Bucket.get(bucket, "milkofcow") == nil
    KV.Bucket.put(bucket, "milkofcow", 3)
    assert KV.Bucket.get(bucket, "milkofcow") == 3
  end


end

Error - (ExUnit.Duplicate Test Error) “test stores values by key”
why i am getting error??

1 Like

You define 2 tests, both have the same name, that is why you see that error.

You can fix it by changing the name of one of the tests.

2 Likes