adamchester / expecto-adapter

Visual Studio test adapter for Expecto (https://github.com/haf/expecto)
MIT License
28 stars 16 forks source link

Tests vanish after being run #43

Open ImaginaryDevelopment opened 6 years ago

ImaginaryDevelopment commented 6 years ago

image after running a single test, it vanishes image

[9/13/2018 1:34:16 PM Informational] ------ Discover test started ------
[9/13/2018 1:34:18 PM Warning] A test with the same name 'unfocused list/focused list/will run' already exists. This test is not added to the test window.
[9/13/2018 1:34:18 PM Warning] A test with the same name 'unfocused list/focused list/will run' already exists. This test is not added to the test window.
[9/13/2018 1:34:18 PM Warning] A test with the same name 'unfocused list/unfocused list/skipped' already exists. This test is not added to the test window.
[9/13/2018 1:34:18 PM Warning] A test with the same name 'unfocused list/unfocused list/will run' already exists. This test is not added to the test window.
[9/13/2018 1:34:18 PM Informational] ========== Discover test finished: 8 found (0:00:01.5445998) ==========
[9/13/2018 1:34:28 PM Informational] ------ Discover test started ------
[9/13/2018 1:34:29 PM Warning] A test with the same name 'unfocused list/focused list/will run' already exists. This test is not added to the test window.
[9/13/2018 1:34:29 PM Warning] A test with the same name 'unfocused list/focused list/will run' already exists. This test is not added to the test window.
[9/13/2018 1:34:29 PM Warning] A test with the same name 'unfocused list/unfocused list/skipped' already exists. This test is not added to the test window.
[9/13/2018 1:34:29 PM Warning] A test with the same name 'unfocused list/unfocused list/will run' already exists. This test is not added to the test window.
[9/13/2018 1:34:29 PM Informational] ========== Discover test finished: 8 found (0:00:00.6426964) ==========
[9/13/2018 1:34:29 PM Informational] ------ Run test started ------
[9/13/2018 1:34:29 PM Informational] Running selected tests
[9/13/2018 1:34:29 PM Informational] Executing tests in assembly C:\projects\HealthDesigns\HD.Tests\bin\Release\HD.Tests.exe
[9/13/2018 1:34:30 PM Informational] Executing tests from: C:\projects\HealthDesigns\HD.Tests\bin\Release\HD.Tests.exe. 1 tests (unfocused list/focused list/will run)
[9/13/2018 1:34:30 PM Informational] All tests: 8
[9/13/2018 1:34:30 PM Informational] Number of tests included: 3
[9/13/2018 1:34:30 PM Informational] ========== Run test finished: 0 run (0:00:00.6765898) ==========
[9/13/2018 1:37:09 PM Informational] ------ Discover test started ------
[9/13/2018 1:37:10 PM Warning] A test with the same name 'unfocused list/focused list/will run' already exists. This test is not added to the test window.
[9/13/2018 1:37:10 PM Warning] A test with the same name 'unfocused list/focused list/will run' already exists. This test is not added to the test window.
[9/13/2018 1:37:10 PM Warning] A test with the same name 'unfocused list/unfocused list/skipped' already exists. This test is not added to the test window.
[9/13/2018 1:37:10 PM Warning] A test with the same name 'unfocused list/unfocused list/will run' already exists. This test is not added to the test window.
[9/13/2018 1:37:10 PM Informational] ========== Discover test finished: 8 found (0:00:00.9541923) ==========
[9/13/2018 1:39:03 PM Informational] ------ Run test started ------
[9/13/2018 1:39:03 PM Informational] Running selected tests
[9/13/2018 1:39:04 PM Informational] Executing tests in assembly C:\projects\HealthDesigns\HD.Tests\bin\Release\HD.Tests.exe
[9/13/2018 1:39:04 PM Informational] Executing tests from: C:\projects\HealthDesigns\HD.Tests\bin\Release\HD.Tests.exe. 1 tests (unfocused list/focused list/will run)
[9/13/2018 1:39:04 PM Informational] All tests: 8
[9/13/2018 1:39:04 PM Informational] Number of tests included: 3
[9/13/2018 1:39:04 PM Informational] ========== Run test finished: 0 run (0:00:00.4897678) ==========

I have only two files after creating a new project targeting 4.6.2

module ConversionsTests

open Expecto

[<Tests>]
let focusedTests =
  testList "unfocused list" [
    ftestList "focused list" [
      testCase "will run" <| fun () -> Expect.equal (2+2) 4 "2+2"
      ftestCase "will run" <| fun () -> Expect.equal (2+2) 4 "2+2"
      test "will run" { Expect.equal (2+2) 4 "2+2" }
    ]
    testList "unfocused list" [
      testCase "skipped" <| fun () -> Expect.equal (2+2) 1 "2+2?"
      ftestCase "will run" <| fun () -> Expect.equal (2+2) 4 "2+2"
      test "skipped" { Expect.equal (2+2) 1 "2+2?" }
      ftest "will run" { Expect.equal (2+2) 4 "2+2" }
    ]
    testCase "skipped" <| fun () -> Expect.equal (2+2) 1 "2+2?"
  ]

and Program.fs

// Learn more about F# at http://fsharp.org
// See the 'F# Tutorial' project for more help.

open System
open Expecto

let tests =
  test "A simple test" {
    let subject = "Hello World"
    Expect.equal subject "Hello World" "The strings should equal"
  }

[<EntryPoint>]
let main args =
  let result = runTestsWithArgs defaultConfig args tests
  Console.ReadLine() |> ignore
  result

if I rebuild the test project the test reappears.

toburger commented 6 years ago

I have the same issue.

olivercoad commented 5 years ago

This happens because you have multiple tests with the same fully qualified name: unfocussed list/focussed list/will run for example could refer to 3 different tests.

From the expecto readme:

You have to remember that the fully qualified names of tests need to be unique across your test project.

If you rename your tests to be unique it works as expected image

Perhaps it could be improved by somehow notifying the user when they have non-unique test names. This would probably need some changes in expecto as well as expecto-adapter.

MNie commented 5 years ago

@olivercoad It is implemented in Expecto.