This page is no longer maintained — Please continue to the home page at www.scala-lang.org

WordSpec: load nested class objects in fixtures

2 replies
Helex
Joined: 2010-03-16,
User offline. Last seen 2 years 30 weeks ago.

Hello guys,

I'm working my way into WordSpec (Scalatest 1.2) and the documentation off
Bill Venners
(file:///home/helex/git-repositories/master-thesis-scala/scala/scalatest-...)
is quite good. I have written the following code:

import org.scalatest.WordSpec

class Bla {
def test(): String = {
"Bla"
}

class Blub {
def blub(): String = {
"Blub"
}
}
val blub = new Blub
}

class TreeSpec extends WordSpec {

def createFixture = {
new Bla
}

"A Test object" should {
"have a method test" in {
val testt = createFixture
assert(testt.blub.blub == "Blub")

}
}

"A Test object" should {
"print arsch" is (pending)
}
}

How can I improve my code? Is it possible to create the object of the nested
class Blub in the fixture and not in the class?

Matthias

H-star Development
Joined: 2010-04-14,
User offline. Last seen 2 years 26 weeks ago.
Re: WordSpec: load nested class objects in fixtures

"arsch" :)

Am 02.01.2011 15:12, schrieb Matthias Guenther:
> Hello guys,
>
> I'm working my way into WordSpec (Scalatest 1.2) and the documentation off
> Bill Venners
> (file:///home/helex/git-repositories/master-thesis-scala/scala/scalatest-...)
> is quite good. I have written the following code:
>
> import org.scalatest.WordSpec
>
> class Bla {
> def test(): String = {
> "Bla"
> }
>
> class Blub {
> def blub(): String = {
> "Blub"
> }
> }
> val blub = new Blub
> }
>
> class TreeSpec extends WordSpec {
>
> def createFixture = {
> new Bla
> }
>
> "A Test object" should {
> "have a method test" in {
> val testt = createFixture
> assert(testt.blub.blub == "Blub")
>
> }
> }
>
> "A Test object" should {
> "print arsch" is (pending)
> }
> }
>
>
> How can I improve my code? Is it possible to create the object of the nested
> class Blub in the fixture and not in the class?
>
> Matthias
>
>

Helex
Joined: 2010-03-16,
User offline. Last seen 2 years 30 weeks ago.
Re: WordSpec: load nested class objects in fixtures

fixed it, I'm not a fan of foo and bar so I just take the fine german
expression :), sorry for that.

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland