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

sbt-mocha fails with "no test suite" when there are nested describes in sbt 1.x #22

Open
btmcnellis opened this issue Nov 30, 2018 · 3 comments

Comments

@btmcnellis
Copy link

In many of my tests, I have nested describe blocks to help organize things, like this:

describe("outer", function() {
    describe("inner", function() {
        it("should do a thing", function() {
            expect(1).to.equal(1);
        });
    });
});

When running sbt-mocha 1.1.2 in an sbt 0.13.17 project, this works perfectly fine. However, when I upgraded the project to sbt 1.2.6, it started failing. Specifically, it would run the tests until it hit a file with a nested describe, then it would run the tests in that file, then it would fail with the following exception:

[error] java.lang.RuntimeException: no test suite
[error] 	at scala.sys.package$.error(package.scala:26)
[error] 	at sbt.JUnitXmlTestsListener.$anonfun$withTestSuite$1(JUnitXmlTestsListener.scala:153)
[error] 	at scala.Option.getOrElse(Option.scala:121)
[error] 	at sbt.JUnitXmlTestsListener.withTestSuite(JUnitXmlTestsListener.scala:153)
[error] 	at sbt.JUnitXmlTestsListener.writeSuite(JUnitXmlTestsListener.scala:230)
[error] 	at sbt.JUnitXmlTestsListener.endGroup(JUnitXmlTestsListener.scala:215)
[error] 	at com.typesafe.sbt.mocha.MochaTestReporting.$anonfun$handleSuite$25(MochaTestReporting.scala:222)
[error] 	at com.typesafe.sbt.mocha.MochaTestReporting.$anonfun$handleSuite$25$adapted(MochaTestReporting.scala:221)
[error] 	at scala.collection.immutable.List.foreach(List.scala:388)
[error] 	at com.typesafe.sbt.mocha.MochaTestReporting.$anonfun$handleSuite$24(MochaTestReporting.scala:221)
[error] 	at com.typesafe.sbt.mocha.MochaTestReporting.$anonfun$handleSuite$24$adapted(MochaTestReporting.scala:220)
[error] 	at scala.Option.foreach(Option.scala:257)
[error] 	at com.typesafe.sbt.mocha.MochaTestReporting.handleSuite(MochaTestReporting.scala:220)
[error] 	at com.typesafe.sbt.mocha.MochaTestReporting.$anonfun$logTestResults$3(MochaTestReporting.scala:81)
[error] 	at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:233)
[error] 	at scala.collection.immutable.List.foreach(List.scala:388)
[error] 	at scala.collection.TraversableLike.map(TraversableLike.scala:233)
[error] 	at scala.collection.TraversableLike.map$(TraversableLike.scala:226)
[error] 	at scala.collection.immutable.List.map(List.scala:294)
[error] 	at com.typesafe.sbt.mocha.MochaTestReporting.logTestResults(MochaTestReporting.scala:78)
[error] 	at com.typesafe.sbt.mocha.SbtMocha$.$anonfun$mochaTestTask$7(SbtMocha.scala:180)
[error] 	at scala.Option.map(Option.scala:146)
[error] 	at com.typesafe.sbt.mocha.SbtMocha$.$anonfun$mochaTestTask$5(SbtMocha.scala:179)
[error] 	at com.typesafe.sbt.mocha.SbtMocha$.$anonfun$projectSettings$15(SbtMocha.scala:128)
[error] 	at com.typesafe.sbt.mocha.SbtMocha$.$anonfun$projectSettings$15$adapted(SbtMocha.scala:112)
[error] 	at scala.Function1.$anonfun$compose$1(Function1.scala:44)
[error] 	at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:40)
[error] 	at sbt.std.Transform$$anon$4.work(System.scala:67)
[error] 	at sbt.Execute.$anonfun$submit$2(Execute.scala:269)
[error] 	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error] 	at sbt.Execute.work(Execute.scala:278)
[error] 	at sbt.Execute.$anonfun$submit$1(Execute.scala:269)
[error] 	at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178)
[error] 	at sbt.CompletionService$$anon$2.call(CompletionService.scala:37)
[error] 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error] 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] 	at java.lang.Thread.run(Thread.java:748)
[error] (foo / mochaOnly) no test suite

If I comment out the inner describe calls so that all the it tests are now on the same level, then the tests run normally again.

I also forked sbt-mocha and modified one of the test files in the scripted tests to do this, and I was able to replicate the issue there as well. Unfortunately, I'm not that familiar with the inner workings of this plugin, so I haven't been able to figure out the root cause yet.

@btmcnellis btmcnellis changed the title sbt-mocha fails when there are nested describes in sbt 1.x sbt-mocha fails with "no test suite" when there are nested describes in sbt 1.x Nov 30, 2018
@Chcap
Copy link

Chcap commented Jun 4, 2020

I encounter the same issue, when using sbt-mocha in version 1.1.2 and sbt 1.3.10. It worked well with sbt 0.13.15.

@atais
Copy link

atais commented Oct 26, 2021

1.5.5 the issue is back. exactly like for @btmcnellis

@mkurz
Copy link
Member

mkurz commented Jan 29, 2024

This still fails, I added you example here to let it run through tests:

I do think MochaTestReporting.scala needs to be adjusted to support nested describes.

If someone comes up with a pull request to fix that I am happy to review.

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

4 participants