All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.scalatestexamples.fixture.suite.TupleFixtureSuite.scala Maven / Gradle / Ivy

Go to download

ScalaTest is a free, open-source testing toolkit for Scala and Java programmers.

The newest version!
package org.scalatestexamples.fixture.suite

import org.scalatest.fixture.FixtureSuite
import scala.collection.mutable.ListBuffer
      
class TupleFixtureSuite extends FixtureSuite {

  type FixtureParam = (StringBuilder, ListBuffer[String])

  def withFixture(test: OneArgTest) {

    // Create needed mutable objects
    val sb = new StringBuilder("ScalaTest is ")
    val lb = new ListBuffer[String]

    // Invoke the test function, passing in the mutable objects
    test(sb, lb)
  }

  def testEasy(fixture: FixtureParam) {
    val (builder, lbuf) = fixture
    builder.append("easy!")
    assert(builder.toString === "ScalaTest is easy!")
    assert(lbuf.isEmpty)
    lbuf += "sweet"
  }

  def testFun(fixture: FixtureParam) {
    val (builder, lbuf) = fixture
    builder.append("fun!")
    assert(builder.toString === "ScalaTest is fun!")
    assert(lbuf.isEmpty)
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy