-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test completed json doesn't include location #368
Comments
This would also be a priority for us, but we would like to get this on non failure items too. So that we can make a test selectable and thus go to it. |
Do you mean the source code line and column number, or something else? |
I guess the line would be enough, but column would be even better. I also thought we might need the file path, but judging from https://github.com/frawa/vscode-elm-test-runner that might not be needed. |
This function node-test-runner/lib/Parser.js Line 27 in c493674
returns a promise resolving to an array of strings which are the names of elm values that might be tests. To solve this I think that the function would have to resolve to an array of some object
and then here
|
Are we talking about the location of
Either way, I don’t know how to find locations in this example (I wrote this here on GitHub so there might be mistakes that don’t compile): module Tests exposing (tests)
import Test
import Expect
tests =
Test.describe "Cool stuff"
[ foo
]
foo = bar
bar =
baz title (body 1)
baz = Test.test
title = "My test title"
body n _ =
check 0 n
check = Tuple.first (Expect.equal, ()) On the other hand, nobody writes tests like that, but in theory that’s what we have to work with. Random note: |
Current implementation of the test runner seems to go to the describe and match the name, so it's rather expensive to do and dumb, as it will break if your test name is generated somehow |
Yeah, of course. My idea in #368 (comment) would give only the location of the top level "test" (in practice it would be a describe block) which isn't that helpful. @lydell is right on the money: we can never come up with a scheme that can locate every test. You can generate tests in all sorts of ways that subvert attempts to locate tests. Even if elm-explorations/test attached location info into Maybe we need to think about alternatives ways of structuring tests, rust uses |
I’ve been thinking along those lines too. In the C#/F# world, tests are commonly marked too (with One way could be to ditch |
The problem with that is that it makes generating many tests impossible. I often have something like: suite =
[ ("foo", 34, True)
, ("bar", 1, False)
-- ...
]
|> List.map (\(name, val, res) ->
Test.test name <|
\() ->
functionUnderTest val
|> Expect.equal res
)
|> Test.desribe "functionUnderTest" (except of course the input list might be generated in some way more complex manner). One solution would be if the runner could execute values that are |
Good point. We’d need some other way of generating tests. |
Here’s another idea for lists of tests: -- Unit test
absTest : Test
absTest =
test "abs" <|
\_ ->
abs -1
|> Expect.equal 1
-- Parameterized test
absTest2 : Test
absTest2 =
each "abs"
[ ( "negative number", ( -1, 1 ) )
, ( "zero", ( 0, 0 ) )
, ( "positive number", ( 1, 1 ) )
]
<|
\( input, expected ) ->
abs input
|> Expect.equal expected
-- Property test
absTest3 : Test
absTest3 =
fuzz Fuzz.int "abs" <|
\input ->
abs input
|> Expect.atLeast 0 |
It would be nice to get the location of the failure. Am I missing something here?
The command I ran was:
elm-test "tests\\RoutingTests.elm" --report json
The current return looks like this:
The text was updated successfully, but these errors were encountered: