开发者

scalatest and SBT issue -- Class is not an accessible org.scalatest.Suite

开发者 https://www.devze.com 2023-03-20 14:53 出处:网络
Revision 5 of my code has an error when running the tests using SBT: https://www.assembla.com/code/opyate-scala-graph-fork-sbt/subversion/changesets/5

Revision 5 of my code has an error when running the tests using SBT:

https://www.assembla.com/code/opyate-scala-graph-fork-sbt/subversion/changesets/5

I've searched the Interwebs for "Class is not an accessible org.scalatest.Suite", but only get results to that message in the scalatest framework code.

Please help me figure out what wrong and if it's a dependency version issue, a compatibility issue, or if the tests are just coded incorrectly.


The details are (one example):

Suites

@RunWith(classOf[JUnitRunner])
class TDegreeRootTest
  extends Suites(
      new TDegree[immutable.Graph](immutable.Graph),
      new TDegree[  mutable.Graph](  mutable.Graph))
  with ShouldMatchers
{
}

Test class

class TDegree[+CC[N,E[X] <: EdgeLikeIn[X]] <: Graph[N,E] with GraphLike[N,E,CC[N,E]]]
    (val factory: GraphCompanion[CC])
    extends Suite
    with    ShouldMatchers
{ ... }

The exception

[error] Could not run test scalax.collection.TDegree:
  java.lang.IllegalArgumentException:
    Class is not an accessible org.scalatest.Suite:
      scalax.collection.TDegree

ScalaTest code that throws exception

The following needs to hold true for clazz an instance of my TDegree:

classOf[Suite].isAssignableFrom(clazz) &&
    Modifier.isPublic(clazz.getModifiers) &开发者_如何转开发&
    !Modifier.isAbstract(clazz.getModifiers) &&
    Modifier.isPublic(clazz.getConstructor(emptyClassArray: _*).getModifiers)

It requires a no-argument constructor, which I don't have.

I guess the question now becomes "How do I get my test classes to run with ScalaTest if my classes do not have a non-argument constructor?".


What that means is that sbt is discovering and handing to ScalaTest a class that is not an accessible suite. That probably means it is package access. If it is public, make sure it has a public no-arg constructor. I'll look at the diffs real quick to see if I can see the culprit.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号