davidB / scala-archetype-simple

a simple maven archetype for project in scala
Creative Commons Zero v1.0 Universal
109 stars 95 forks source link

JUnit tests skiped #20

Open agebhar1 opened 8 years ago

agebhar1 commented 8 years ago

Prior to #15 tests are invoked via Maven Surefire. After merge of this MR tests are invoked via scalatest-maven-plugin and skip JUnit test(s)

package samples

import org.junit._
import Assert._

@Test
class AppTest {

    @Test
    def testOK() = assertTrue(true)

//  @Test
//  def testKO() = assertTrue(false)

}

Output:

Discovery starting.
Discovery completed in 171 milliseconds.
Run starting. Expected test count is: 5
ListSuite:
- An empty list should be empty
- A non-empty list should not be empty
- A list's length should equal the number of elements it contains
ExampleSpec:
A Stack
- should pop values in last-in-first-out order
- should throw NoSuchElementException if an empty stack is popped
Run completed in 302 milliseconds.
Total number of tests run: 5
Suites: completed 3, aborted 0
Tests: succeeded 5, failed 0, canceled 0, ignored 0, pending 0
All tests passed.

After enable failing test:

package samples

import org.junit._
import Assert._

@Test
class AppTest {

    @Test
    def testOK() = assertTrue(true)

    @Test
    def testKO() = assertTrue(false)

}

Output:

Discovery starting.
Discovery completed in 143 milliseconds.
Run starting. Expected test count is: 5
ListSuite:
- An empty list should be empty
- A non-empty list should not be empty
- A list's length should equal the number of elements it contains
ExampleSpec:
A Stack
- should pop values in last-in-first-out order
- should throw NoSuchElementException if an empty stack is popped
Run completed in 257 milliseconds.
Total number of tests run: 5
Suites: completed 3, aborted 0
Tests: succeeded 5, failed 0, canceled 0, ignored 0, pending 0
All tests passed.

still all tests passed. The number of expected tests misses the JUnit tests.

The pull request #19 adds the missing JUnit tests to scalatest-maven-plugin's configuration. See also ScalaTest Maven Plugin

Output on applied #19 (with failing JUnit test)

Run starting. Expected test count is: 2
JUnitWrapperSuite:
- testKO *** FAILED ***
  java.lang.AssertionError:
  at org.junit.Assert.fail(Assert.java:86)
  at org.junit.Assert.assertTrue(Assert.java:41)
  at org.junit.Assert.assertTrue(Assert.java:52)
  at samples.AppTest.testKO(junit.scala:13)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
  at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
  ...
- testOK
Run completed in 112 milliseconds.
Total number of tests run: 2
Suites: completed 1, aborted 0
Tests: succeeded 1, failed 1, canceled 0, ignored 0, pending 0
*** 1 TEST FAILED ***
agebhar1 commented 8 years ago

:disappointed: ... now ScalaTest and Specs2 tests are missing