0

I am trying to autopopulate a bunch of database objects in Scala Play. I've been able to do it successfully so far, but only by disguising my script as a test and running it with activator test-only.

Can someone give me some guidance as to how to convert the below test into a script that I can run outside of activator test?

my code

import java.awt
import java.util.concurrent.TimeUnit
import org.scalatestplus.play._
import org.openqa.selenium._
import com.sun.xml.internal.bind.v2.TODO
import scala.collection.JavaConverters._
import controllers.Application
import models.Item
import play.api.test._
import org.scalatest.time._
import org.apache.commons.lang3.RandomStringUtils
import java.util.Random

class ItemGenerator extends PlaySpec with OneServerPerSuite {

  implicit override lazy val app: FakeApplication =
    FakeApplication(additionalConfiguration = TestUtil.inMemoryDatabase("default", Map()))

  "Generator" should {
    "create a bunch of items" in {
      Item.deleteAll()

      val rand = new Random(System.currentTimeMillis())

      for (x <- 1 to 100) {
      Item.create()
      }
    }
  }
}

Thanks,

Joe

Driver
  • 317
  • 1
  • 4
  • 18

0 Answers0