- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
WordSpec: load nested class objects in fixtures
Sun, 2011-01-02, 15:12
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
Sun, 2011-01-02, 15:37
#2
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.
"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
>
>