agtors / agar.core

Actor core system for simple Agar implementation
Apache License 2.0
2 stars 0 forks source link

Add tests for the steering behavior #22

Closed NotBad4U closed 6 years ago

NotBad4U commented 6 years ago

Work to complete #1 #2 #3

This PR:

Please help if you know how to compare 2 double with just a precision at 10^-2. I need to dos this: should be (new Vector2d(-4.567868516922847, -3.5511451511049703)) but I'll prefer something like should be (new Vector2d(-4.56, -3.55))

For now, my test look like this:

"An entity" should "...." in {

 }

"An entity" should "....." in {

  }

But that give me this output in the test repport:

[info] An entity
[info] - should move toward the target with steer behavior
[info] An entity
[info] - should run away from the target with flee behavior
[info] An entity
[info] - should be able to pursuit a target
[info] An entity

Where I prefer something like (only one "An entity"):

[info] An entity
[info] - should move toward the target with steer behavior
[info] - should run away from the target with flee behavior
[info] - should be able to pursuit a target

I tried to make my code like that:

class Yolo extend FlatSpec with Matchers with WordSpecLike {
  "An entity" should{
      "...." in {

      "....." in {
     }
   }
}

but I got this error:

[info] Loading settings from plugins.sbt ...
[info] Loading project definition from /home/alessio/Talks/Actor/agar.core/project
[info] Loading settings from build.sbt ...
[info] Set current project to agar.core (in build file:/home/alessio/Talks/Actor/agar.core/)
[info] Compiling 1 Scala source to /home/alessio/Talks/Actor/agar.core/target/scala-2.12/test-classes ...
[error] /home/alessio/Talks/Actor/agar.core/src/test/scala/com/agar/core/behaviors/BehaviorsSpec.scala:9:7: class BehaviorsSpec inherits conflicting members:
[error]   method info in trait FlatSpecLike of type => org.scalatest.Informer  and
[error]   method info in trait WordSpecLike of type => org.scalatest.Informer
[error] (Note: this can be resolved by declaring an override in class BehaviorsSpec.);
[error]  other members with override errors are: note, alert, markup, registerTest, registerIgnoredTest, it, they, behave, styleName
[error] class BehaviorsSpec() extends FlatSpec with Matchers with WordSpecLike{
[error]       ^
[error] one error found
[error] (Test / compileIncremental) Compilation failed
[error] Total time: 3 s, completed Nov 6, 2018 1:01:25 AM

What I understand is the combo with extend FlatSpec with Matchers with WordSpecLike is not correct.

d-plaindoux commented 6 years ago

Your test behaviors can be changed removing FlatSpec and adding WordSpec inheritance like this:


class BehaviorsSpec() extends WordSpec with Matchers {

  val MAX_VELOCITY: Short = 3: Short

  "An entity" should {
    "move toward the target with steer behavior" in {
    ...
    }

    "run away from the target with flee behavior" in {
      ...
    }

    "be able to pursuit a target" in {
      ...
    }

    "be evade from a pursuer" in {
      ...
    }
  }

}```