tests are great, having them integrated is really nice
I have questions:
1. Why aren't tests running on compilation, but only on execution?
if I am developing a library, I would run cobra -test, but sometimes forget to.
would be nice to have the default check them on every compilation.
2. when running -test, the tests in the included libraries (use xx) are also run.
isn't it redundant?
Forums
about tests
6 posts
• Page 1 of 1
about tests
Falun Dafa is Good.
Truth, Compassion, Forbearance is Good.
Truth, Compassion, Forbearance is Good.
- kobi7
- Posts: 82
- Location: Israel
Re: about tests
1. People aren't expecting their code to be executed when they compile. And especially in Cobra where you add -c to get "compilation only", I don't think it would fit. If your project is a library, you could have a build target or script committed to testing.
2. Yeah it is redundant and should probably be eliminated. It might be nice to have an option to run them all though.
2. Yeah it is redundant and should probably be eliminated. It might be nice to have an option to run them all though.
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: about tests
fair enough, on both points. I guess you're right it is the appropriate behaviour
btw, is there a short or conciser output for tests?
right now I get something of a tree...
coloring would also be a nice feature.
btw, is there a short or conciser output for tests?
right now I get something of a tree...
coloring would also be a nice feature.
Falun Dafa is Good.
Truth, Compassion, Forbearance is Good.
Truth, Compassion, Forbearance is Good.
- kobi7
- Posts: 82
- Location: Israel
Re: about tests
I have changed the default behavior of -test to only run the tests of the given program (or library) and not the libraries it references.
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: about tests
I'll make a proper wiki page for this, but briefly, to customize the test output:
-- See "cobra -help" for the -test-runner option:
So something like:
-- See CobraCore.cobra for an example implementation:
-- Provide your own implementation of ITestRunListener to pass to the TestRunner class. You can find the interface and two implementations in Test.cobra of the Cobra.Core library:
http://cobra-language.com/trac/cobra/br ... Test.cobra
Let us know if you have any problems.
-- See "cobra -help" for the -test-runner option:
- Code: Select all
-test-runner[:QUALIFIED-METHOD-NAME|nil] default is Cobra.Core.CobraCore.runAllTests
Specify the method to invoke to run the unit tests. The method must be "shared". Typically the method will make use of classes in Cobra.Core.Test to set up and initiate the test run.
So something like:
- Code: Select all
cobra -test -test-running:MyProgram.runTests MyProgram.cobra
-- See CobraCore.cobra for an example implementation:
def runAllTests is shared
"""
Run all Cobra sections in all assemblies using reflection to locate them.
"""
if CobraImp.showTestProgress, listener = Cobra.Core.Test.TextWriterListener(Console.out)
else, listener = Cobra.Core.Test.TextWriterOnlyOnFailureListener(Console.out)
tr = Cobra.Core.Test.TestRunner(listener)
tr.runAllTests
if listener.testFailures, CobraCore.exit(1)
-- Provide your own implementation of ITestRunListener to pass to the TestRunner class. You can find the interface and two implementations in Test.cobra of the Cobra.Core library:
http://cobra-language.com/trac/cobra/br ... Test.cobra
Let us know if you have any problems.
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: about tests
I'm stoked about the recent change to -test and can't wait to try it out. However, regarding...
I have to agree with kobi that when I was first trying Cobra, I was surprised that tests were not being run automatically for libraries.
Charles wrote:1. People aren't expecting their code to be executed when they compile. And especially in Cobra where you add -c to get "compilation only", I don't think it would fit. If your project is a library, you could have a build target or script committed to testing.
I have to agree with kobi that when I was first trying Cobra, I was surprised that tests were not being run automatically for libraries.
- nerdzero
- Posts: 286
- Location: Chicago, IL
6 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 29 guests