scalatest

Unit testing several implementation of the same trait/interface

I program mostly in scala and java, using scalatest in scala and junit for unit testing. I would like to apply the very same tests to several implementations of the same interface/trait. The idea is to verify that the interface contract is enforced and to check Liskov substitution principle. For instance, when testing implementations of...

Can ScalaCheck/Specs warnings safely be ignored when using SBT with ScalaTest?

I have a simple FunSuite-based ScalaTest: package pdbartlett.hello_sbt import org.scalatest.FunSuite class SanityTest extends FunSuite { ...

How can I run scalatest in jEdit or Eclipse?

I'm teaching a course in Scala, starting just after the Fourth of July. I'd like to teach scalatest, but I cannot get it to work. By preference I'd like to get it working with jEdit and the ScalaMiniIDE plugin. That requires Maven, which I don't know at all. jEdit has a Maven 0.3 plugin and a Maven2 1.3 plugin (the latter won't load) an...

ScalaTest: Issues with Singleton Object re-initialization

I am testing a parser I have written in Scala using ScalaTest. The parser handles one file at a time and it has a singleton object like following: class Parser{...} object Resolver {...} The test case I have written is somewhat like this describe("Syntax:") { val dir = new File("tests\\syntax"); val files = dir.listFiles.f...

Scala: Defining test cases based on folder

I have to test a program which takes one input file. I have put all the input files inside a folder and now I want to use SBT and ScalaTest to have following features: TestAll : Invoke the program with one input file at a time for all files Test one: Invoke the program with one input file provided as argument to test command from sbt c...

Undercover code coverage with ant and scalatest

After a lot of trying and searching around, I still could not get undercover to work with ant and scalatest. although there is no error, The report always shows 0% eventhough I have test cases. Below is the relevant part of my build.xml <target name="instrumentClasses" depends="test"> <taskdef resource="undercover-ant.properties" classp...

ScalaTest: check for contents of a sequence with ShouldMatcher

In my unit test, I want to express that a computed (result) sequence yielded a predefined sequence of result values. But without assuming anything about the actual implementation type of the sequence container. And I want to spell out my intent rather clear and self-explanatory. If I try to use the "ShouldMatchers" of ScalaTest and writ...

Ways to improve this code

I am trying to write some test code for my java application using Scalatest. I figured, since Scala has so much more readable syntax it would result with more readable test code. So far, this is what I managed: package com.xyz import org.scalatest.FlatSpec import org.scalatest.matchers.ShouldMatchers import com.xyz.SecurityService ...

How to populate java.util.HashMap on the fly from Scala code?

I am unit testing java code from ScalaTest and would like to populate a java.util.HashMap within the same statement it gets declared. Is it possible to do this in Scala? ...