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 testing #68

Open
Night-walker opened this issue Aug 3, 2015 · 8 comments
Open

Unit testing #68

Night-walker opened this issue Aug 3, 2015 · 8 comments

Comments

@Night-walker
Copy link
Collaborator

While daotest is suitable for testing the DaoVM (e.g., it is able to properly test parsing and typing mechanics), I felt the need to have an assertion-based test framework I could use for standard modules. So here it is.

Simple example:

load test
import test.{@test, assertNone, assertEqual}

@test
routine passingTest(){
    assertEqual(2*2, 4)
}

@test('nonsense')
routine failingTest(){
    assertNone(1)
}

@test
routine skippedTest(){
    test.skipTest()
}

routine main(){
    test.runTests()
}

Output:

1. passingTest passed
2. nonsense failed -- line 11: expected none, found 1
3. skippedTest skipped
Summary: 3 tests, 1 passed, 1 failed, 1 skipped

Currently, test.runTest() just dumbly runs all global routines matching prefix. Would be nice if it was possible to sort it out by picking only @test-decorated routines (this issue).

@daokoder
Copy link
Owner

daokoder commented Aug 3, 2015

Nice, this could also be more user friendly for testing applications.

@Night-walker
Copy link
Collaborator Author

Also, line number detection for unexpectedly raised errors is highly desirable. Currently this information is unavailable.

@dumblob
Copy link

dumblob commented Aug 5, 2015

Also, line number detection for unexpectedly raised errors is highly desirable. Currently this information is unavailable.

Somewhat related to daokoder/dao#298 .

@daokoder
Copy link
Owner

daokoder commented Aug 6, 2015

Also, line number detection for unexpectedly raised errors is highly desirable. Currently this information is unavailable.

Now it is made available.

@daokoder
Copy link
Owner

daokoder commented Aug 6, 2015

BTW, I prefer we rename this module, something like testing, or unitest, or unittest. The reason is that test is such a common name that, when one wants to write something for testing, very likely it will be named as test.dao.

@Night-walker
Copy link
Collaborator Author

Right, testing would be fine.

@Night-walker
Copy link
Collaborator Author

Exception::.line() does not give correct line number. For instance, the example above reports error at line 3 if the new method is utilized.

@Night-walker
Copy link
Collaborator Author

Now there is a problem with the decorator. When I do DaoProcess_Call() on a 'decoratee' of @test (the latter is passed manually to runTests()), it looks like @test itself does not run -- error in a failing test is not caught.

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

3 participants