Skip to content
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

Unit tests #33

Open
zacck-zz opened this issue Apr 5, 2017 · 7 comments
Open

Unit tests #33

zacck-zz opened this issue Apr 5, 2017 · 7 comments

Comments

@zacck-zz
Copy link
Contributor

zacck-zz commented Apr 5, 2017

No description provided.

@zacck-zz
Copy link
Contributor Author

zacck-zz commented Apr 5, 2017

Hello guys!
So I am trying to implement unit tests for the application. I understand that currently we only have sample tests. Can anyone advice on a test runner to use for this and any documentation to guide if possible.

@akabiru
Copy link
Collaborator

akabiru commented Apr 5, 2017

@zacck the test runner is already defined. We integrated elm-test for that.

@zacck-zz
Copy link
Contributor Author

zacck-zz commented Apr 5, 2017

@akabiru aweh! So I am having a tiny problem: I added a new sample test file
sampletest.elm

myTest = test "Example Test" (assert True)

But when I run yarn test the only tests that run and pass are the ones that passed before I added mine, So mine neither passes nor fails vis a vis doesn't run. I suspect I am adding the test wrongly could you run me through adding a test? Much Regards!

@zacck-zz
Copy link
Contributor Author

zacck-zz commented Apr 5, 2017

Ok I think I have a handle on this I have now got a test failing.
Great Success.
My new Test goes as follows,
Sample

module Sample exposing (..)
import Test exposing(..)
import Expect
all : Test
all =
  describe "New Test Case"
      [ sampleTest]

sampleTest : Test
sampleTest =
    describe "Sample 1"
    [ test "New Test" <|
      \() ->
        Expect.equal(3 + 3) 7]

My current issue is that I can't run this in conjunction with the other existing tests i.e Tests

I have changed TestRunner as such

port module TestRunner exposing (..)

import Tests
import Test.Runner.Node exposing (run, TestProgram)
import Json.Encode exposing (Value)
import Sample


main : TestProgram
main =
    run emit Sample.all


port emit : ( String, Value ) -> Cmd msg

Could anyone help me with running a list as [Sample.all, Tests.all] doesn't yield

@akabiru
Copy link
Collaborator

akabiru commented Apr 5, 2017

@zacck You're on the right track. Once you have your test in SampleTest.elm

module SampleTest exposing (myTest)

myTest =
    test "Example Test" (assert True)

You can then import the module in Tests.elm and add them to the describe list.

module Tests exposing (..)

import Test exposing (..)
import SampleTest exposing(myTest)
import Expect
import Fuzz exposing (list, int, tuple, string)
import String


all : Test
all =
    describe "Sample Test Suite"
        [ unitTestExample
        , fuzzTestsExample
        , myTest
        ]
-- Rest of the code

@zacck-zz
Copy link
Contributor Author

zacck-zz commented Apr 6, 2017

@waiyaki aweh! Ok I think we have handle on this I had to modify your example just a tiny bit so my Tests file ended up looking as such

import String
import Sample


all : Test
all =
    describe "Sample Test Suite"
        [ unitTestExample
        , fuzzTestsExample
        , Sample.sampleTest
        ]

Following this the tests run and my failing test does fail.
Will add a PR to start working on the tests as we document the components and learn what they are supposed to do I can add tests for them.

@akabiru
Copy link
Collaborator

akabiru commented Apr 6, 2017

Awesome!! Looking forward to that! 🕺🏽

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants