Невозможно получить структуру FeatureSpec для отображения в выходных данных в сочетании с JUnitSuite - PullRequest
1 голос
/ 09 ноября 2009

Я пытаюсь использовать возможности Scala для запуска класса с помощью JUnit или ScalaTest. Я взял пример, приведенный для FeatureSpec, и соединил его с примером, используя JUnitSuite. У меня возникла проблема при создании данного / когда / затем вывод структуры Scalatest.FeatureSpec в вывод (консоль) при сочетании с JUnitSuite. Любая обратная связь будет принята с благодарностью. Нужно знать, возможно ли это вообще. Заранее спасибо.

код:

import collection.mutable.Stack
import org.junit.Test
import org.scalatest.junit.JUnitSuite
import org.scalatest.matchers.MustMatchers
import org.scalatest.{GivenWhenThen, FeatureSpec}

class ExampleSpecTest extends FeatureSpec with JUnitSuite with GivenWhenThen with MustMatchers
{

@Test
 def featureSpecExample() {
   feature("The user can pop an element off the top of the stack") {

     info("As a programmer")
     info("I want to be able to pop items off the stack")
     info("So that I can get them in last-in-first-out order")

     scenario("pop is invoked on a non-empty stack") {

       given("a non-empty stack")
       val stack = new Stack[Int]
       stack.push(1)
       stack.push(2)
       val oldSize = stack.size

       when("when pop is invoked on the stack")
       val result = stack.pop()

       then("the most recently pushed element should be returned")
       result must be === 2

       and("the stack should have one less item than before")
       stack.size must be === oldSize - 1
     }

     scenario("pop is invoked on an empty stack") {

       given("an empty stack")
       val emptyStack = new Stack[String]

       when("when pop is invoked on the stack")
       then("NoSuchElementException should be thrown")
       evaluating { emptyStack.pop() } must produce [NoSuchElementException]

       and("the stack should still be empty")
       emptyStack must be ('empty)
     }
   }
 }
}

когда я запускаю эту версию ExampleSpecTest, я получаю следующий вывод:

Run starting. Expected test count is: 1
ExampleSpecTest:
Test Starting - ExampleSpecTest: featureSpecExample
Test Succeeded - ExampleSpecTest: featureSpecExample
Run completed in 255 milliseconds.
Total number of tests run: 1
Suites: completed 1, aborted 0
Tests: succeeded 1, failed 0, ignored 0, pending 0
All tests passed.

Я не получаю ожидаемых данных / когда / затем в отчете

Ожидаемое:

Run starting. Expected test count is: 1
ExampleSpecTest:
Test Starting - ExampleSpecTest: featureSpecExample
Feature: The user can pop an element off the top of the stack  
   As a programmer  
   I want to be able to pop items off the stack  
   So that I can get them in last-in-first-out order  
   Scenario: pop is invoked on a non-empty stack
      Given a non-empty stack    
      When when pop is invoked on the stack    
      Then the most recently pushed element should be returned    
      And the stack should have one less item than before  
   Scenario: pop is invoked on an empty stack
      Given an empty stack    
      When when pop is invoked on the stack    
      Then NoSuchElementException should be thrown    
      And the stack should still be empty
Test Succeeded - ExampleSpecTest: featureSpecExample Run completed in 96 milliseconds.
Total number of tests run: 2
Suites: completed 1, aborted 0
Tests: succeeded 1, failed 0, ignored 0, pending 0
All tests passed.
...