Class

io.github.soc.testng

ScalaJSTestNGPlugin

Related Doc: package testng

Permalink

class ScalaJSTestNGPlugin extends Plugin

The Scala.js TestNG plugin is a way to overcome the lack of annotation information of any test class (usually accessed through reflection). This is all the information required by the Scala.js testing framework to execute the tests.

As an example we take the following test class:

class Foo {
  @BeforeMethod def before(): Unit = {
    // Initialize the instance before the tests
  }
  @Test def bar(): Unit = {
    // assert some stuff
  }
  @Test(enabled = false) def baz(): Unit = {
    // assert some other stuff
  }
}

object Foo {
  @BeforeClass def beforeClass(): Unit = {
    // Initialize some global state for the tests.
  }
}

Will generate the following bootstrapper module:

object Foo$scalajs$testng$bootstrapper extends io.github.soc.testng.TestNGTestBootstrapper {

  def metadata(): TestNGClassMetadata = {
    new TestNGClassMetadata(
      classAnnotations = List(),
      moduleAnnotations = List(),
      classMethods = List(
          new TestNGMethodMetadata(name = "before",
              annotations = List(new BeforeMethod)),
          new TestNGMethodMetadata(name = "bar",
              annotations = List(new Test)),
          new TestNGMethodMetadata(name = "baz",
              annotations = List(new Test(enabled = false)))
      ),
      moduleMethods(
          new TestNGMethodMetadata(name = "beforeClass",
              annotations = List(new BeforeClass)))
    )
  }

  def newInstance(): AnyRef = new Foo()

  def invoke(methodName: String): Unit = {
    if (methodName == "0") Foo.beforeClass()
    else throw new NoSuchMethodException(methodId)
  }

  def invoke(instance: AnyRef, methodName: String): Unit = {
    if (methodName == "before") instance.asInstanceOf[Foo].before()
    else if (methodName == "bar") instance.asInstanceOf[Foo].bar()
    else if (methodName == "baz") instance.asInstanceOf[Foo].baz()
    else throw new NoSuchMethodException(methodId)
  }
}

The test framework will identify Foo$scalajs$testng$bootstrapper as a test module because it extends TestNGTestBootstrapper. It will know which methods to run based on the info returned by Foo$scalajs$testng$bootstrapper.metadata, it will create new test instances using Foo$scalajs$testng$bootstrapper.newInstance() and it will invoke test methods using invoke on the bootstrapper.

Linear Supertypes
Plugin, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ScalaJSTestNGPlugin
  2. Plugin
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ScalaJSTestNGPlugin(global: Global)

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. object ScalaJSTestNGPluginComponent extends PluginComponent with Transform with Compat210Component

    Permalink
  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. val components: List[PluginComponent]

    Permalink
    Definition Classes
    ScalaJSTestNGPlugin → Plugin
  8. val description: String

    Permalink
    Definition Classes
    ScalaJSTestNGPlugin → Plugin
  9. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  11. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  13. val global: Global

    Permalink
    Definition Classes
    ScalaJSTestNGPlugin → Plugin
  14. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  15. def init(options: List[String], error: (String) ⇒ Unit): Boolean

    Permalink
    Definition Classes
    Plugin
  16. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  17. val name: String

    Permalink
    Definition Classes
    ScalaJSTestNGPlugin → Plugin
  18. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  19. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  20. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  21. def options: List[String]

    Permalink
    Definition Classes
    Plugin
  22. val optionsHelp: Option[String]

    Permalink
    Definition Classes
    Plugin
  23. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  24. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  25. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. def processOptions(options: List[String], error: (String) ⇒ Unit): Unit

    Permalink
    Definition Classes
    Plugin
    Annotations
    @deprecated
    Deprecated

    (Since version 2.11) use Plugin#init instead

Inherited from Plugin

Inherited from AnyRef

Inherited from Any

Ungrouped