Skip to content

JUnit tests defined in traits will crash the compiler with test.Test0.initializationError failed #7949

Closed
@molikto

Description

@molikto

minimized code

See this repo:

https://github.com/molikto/dotty-test

Compilation output
[error] Test test.Test0.initializationError failed: java.lang.Exception: Test class should have exactly one public constructor, took 0.002 sec
[error]     at com.novocode.junit.JUnitRunner$1.execute(JUnitRunner.java:124)
[error]     at sbt.TestRunner.runTest$1(TestFramework.scala:113)
[error]     at sbt.TestRunner.run(TestFramework.scala:124)
[error]     at sbt.TestFramework$$anon$2$$anonfun$$lessinit$greater$1.$anonfun$apply$1(TestFramework.scala:282)
[error]     at sbt.TestFramework$.sbt$TestFramework$$withContextLoader(TestFramework.scala:246)
[error]     at sbt.TestFramework$$anon$2$$anonfun$$lessinit$greater$1.apply(TestFramework.scala:282)
[error]     at sbt.TestFramework$$anon$2$$anonfun$$lessinit$greater$1.apply(TestFramework.scala:282)
[error]     at sbt.TestFunction.apply(TestFramework.scala:294)
[error]     at sbt.Tests$.$anonfun$toTask$1(Tests.scala:309)
[error]     at sbt.std.Transform$$anon$3.$anonfun$apply$2(System.scala:46)
[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:264)
[error]     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[error]     at java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error]     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[error]     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[error]     at java.lang.Thread.run(Thread.java:834)
[debug] Test test.Test0.initializationError finished, took 0.006 sec
[debug] Test run finished: 1 failed, 0 ignored, 1 total, 0.008s

expectation

Traits should not be traited as a test class, changing traits to abstract class works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions