class ScalaJSJUnitPlugin extends Plugin
The Scala.js jUnit 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 { @Before def before(): Unit = { // Initialize the instance before the tests } @Test def bar(): Unit = { // assert some stuff } @Ignore("baz not implemented yet") @Test 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$junit$bootstrapper extends org.scalajs.junit.JUnitTestBootstrapper { def metadata(): JUnitClassMetadata = { new JUnitClassMetadata( classAnnotations = List(), moduleAnnotations = List(), classMethods = List( new JUnitMethodMetadata(name = "before", annotations = List(new Before)), new JUnitMethodMetadata(name = "bar", annotations = List(new Test)), new JUnitMethodMetadata(name = "baz", annotations = List(new Test, new Ignore("baz not implemented yet"))) ), moduleMethods( new JUnitMethodMetadata(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$junit$bootstrapper
as a test module
because it extends JUnitTestBootstrapper
. It will know which methods to run based
on the info returned by Foo$scalajs$junit$bootstrapper.metadata,
it will create new test instances using Foo$scalajs$junit$bootstrapper.newInstance()
and it will invoke test methods using invoke
on the bootstrapper.
Linear Supertypes
Ordering
- Alphabetic
- By Inheritance
Inherited
- ScalaJSJUnitPlugin
- Plugin
- AnyRef
- Any
- Hide All
- Show All
Visibility
- Public
- All
Instance Constructors
- new ScalaJSJUnitPlugin(global: Global)
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
val
components: List[PluginComponent]
- Definition Classes
- ScalaJSJUnitPlugin → Plugin
-
val
description: String
- Definition Classes
- ScalaJSJUnitPlugin → Plugin
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
val
global: Global
- Definition Classes
- ScalaJSJUnitPlugin → Plugin
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
def
init(options: List[String], error: (String) ⇒ Unit): Boolean
- Definition Classes
- Plugin
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
val
name: String
- Definition Classes
- ScalaJSJUnitPlugin → Plugin
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
def
options: List[String]
- Definition Classes
- Plugin
-
val
optionsHelp: Option[String]
- Definition Classes
- Plugin
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
- object ScalaJSJUnitPluginComponent extends PluginComponent with Transform with Compat210Component