Forums

about tests

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

about tests

Postby kobi7 » Sun Nov 11, 2012 4:30 am

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?
Falun Dafa is Good.
Truth, Compassion, Forbearance is Good.
kobi7
 
Posts: 82
Location: Israel

Re: about tests

Postby Charles » Sun Nov 11, 2012 1:31 pm

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.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: about tests

Postby kobi7 » Tue Nov 13, 2012 3:43 am

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.
Falun Dafa is Good.
Truth, Compassion, Forbearance is Good.
kobi7
 
Posts: 82
Location: Israel

Re: about tests

Postby Charles » Fri Nov 16, 2012 8:58 pm

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

Postby Charles » Fri Nov 16, 2012 11:45 pm

I'll make a proper wiki page for this, but briefly, to customize the test output:

-- 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

Postby nerdzero » Mon Nov 19, 2012 2:32 pm

I'm stoked about the recent change to -test and can't wait to try it out. However, regarding...

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


Return to Discussion

Who is online

Users browsing this forum: No registered users and 43 guests