Download E-books Testing in Scala PDF

By Daniel Hinojosa

Daniel Hinojosa, "Testing in Scala" English | ISBN: 1449315119 | 2013 | writer: O’Reilly Media | PDF | 166 pages | 6 + 1 MB

If you construct your Scala software via Test-Driven improvement, you’ll fast see the benefits of checking out prior to you write construction code. This hands-on booklet exhibits you the way to create checks with ScalaTest and the Specs2—two of the simplest checking out frameworks available—and the best way to run your assessments within the easy construct software (SBT) designed in particular for Scala projects.

By construction a pattern electronic jukebox program, you’ll detect the way to isolate your assessments from huge subsystems and networks with mocking code, and the way to exploit the ScalaCheck library for computerized specification-based checking out. If you’re accustomed to Scala, Ruby, or Python, this ebook is for you.
Get an summary of Test-Driven Development
Start an easy undertaking with SBT and create assessments ahead of you write code
Dive into SBT’s easy instructions, interactive mode, packaging, and history
Use ScalaTest either within the command line and with SBT, and how to contain JUnit and TestNG
Work with the Specs2 framework, together with Specification kinds, matchers DSLs, and knowledge Tables
Understand mocking through the use of Java frameworks EasyMock and Mockito, and the Scala-only framework ScalaMock
Automate checking out through the use of ScalaCheck to generate pretend information

Show description

Read or Download Testing in Scala PDF

Similar Development books

Software and System Development using Virtual Platforms: Full-System Simulation with Wind River Simics

Digital systems are discovering common use in either pre- and post-silicon software program and procedure improvement. They decrease time to industry, increase process caliber, make improvement extra effective, and permit really concurrent hardware/software layout and bring-up. digital systems bring up productiveness with remarkable inspection, configuration, and injection functions.

Starting Out with Java: From Control Structures through Objects (6th Edition)

Be aware: you're buying a standalone product; MyProgrammingLab® does now not come packaged with this content material. if you want to buy either the actual textual content and MyProgrammingLab look for 0134059875 / 9780134059877     beginning Out with Java: From regulate buildings via items plus MyProgrammingLab with Pearson eText -- entry Card package deal, 6/e   package deal contains: 0133957055 / 9780133957051 beginning Out with Java: From regulate buildings via items, 6/e 0133885569 / 9780133885569 0133957608 / 9780133957600 MyProgrammingLab with Pearson eText -- entry Card -- for beginning Out with Java: From regulate constructions via items, 6/e MyProgrammingLab should still purely be bought while required through an teacher.

Ground Control: Fear and Happiness in the Twenty-First-Century City

While the figures say crime is falling, why are we extra anxious than ever? may possibly our cities and towns be developing worry and distrust? extra estate is being in-built Britain than at any time because the moment international warfare - yet it truly is owned through inner most organizations, designed for revenue and watched over by way of CCTV.

Refactoring: Improving the Design of Existing Code

Because the software of item technology--particularly the Java programming language--has turn into general, a brand new challenge has emerged to confront the software program improvement group. major numbers of poorly designed courses were created by means of less-experienced builders, leading to purposes which are inefficient and difficult to keep up and expand.

Extra resources for Testing in Scala

Show sample text content

It introduced many new rules to the Java checking out worlds, together with DataProviders—which supplies an inventory of knowledge to a checking out method—and groups—which are analogous to tagging in ScalaTest. those are just the various good points incorporated in TestNG. ScalaTest takes nice care to make sure that all of the TestNG positive factors paintings less than ScalaTest. First, it’s essential to comprise testng within the libraryDependencies surroundings of construct. sbt. under is a snippet to incorporate the a testng dependency within the Seq of dependency vectors. libraryDependencies ++= Seq("org. scalatest" % "scalatest_2. nine. 2" % "1. eight" % "test" withSources() withJavadoc(), "joda-time" % "joda-time" % "1. eight" withSources() withJavadoc(), "junit" % "junit" % "4. 10" withSources() withJavadoc(), "org. testng" % "testng" % "6. 1. 1" % "test" withSources() withJavadoc()) After finishing the reload and replace required to deliver the testng dependency into the undertaking, the subsequent is a pattern of a TestNG attempt utilized in ScalaTest utilizing a DataProvider and TestNG teams. package deal com. oreilly. testingscala import org. scalatest. testng. TestNGSuite import assortment. mutable. ArrayBuilder import org. testng. annotations. {Test, DataProvider} import org. testng. Assert. _ classification ArtistTestNGSuite extends TestNGSuite { @DataProvider(name = "provider") def provideData = { val g = new ArrayBuilder. ofRef[Array[Object]]() g += (Array[Object]("Heart", five. asInstanceOf[java. lang. Integer])) g += (Array[Object]("Jimmy Buffet", 12. asInstanceOf[java. lang. Integer])) g. result() } @Test(dataProvider = "provider") def testTheStringLength(n1:String, n2:java. lang. Integer) { assertEquals(n1. size, n2) } } provideData is a technique that returns an Array[Array[Object]] with try out info used for the try. provideData can also be annotated with @DataProvider and given an arbitrary identify: supplier. the information supplied by way of the supplier will name a try approach asking for the information utilizing the dateProvider parameter in a try annotation. within the related, testTheStringLength technique is annotated with try and requests the information supplier named supplier. The testTheStringLength will now turn into tests—one for every row of information supplied by means of the supplier. This technique cuts boilerplate code down, and provides the try developer and a unmarried element of concentration for trying out. lower than are the implications generated from ArtistTestNGSuite. > ~test-only com. oreilly. testingscala. ArtistTestNGSuite [TestNG] operating: Command line suite \=============================================== Command line suite overall assessments run: 2, mess ups: zero, Skips: zero \=============================================== [info] ArtistTestNGSuite: [info] ArtistTestNGSuite: [info] - testTheStringLength(Heart,5) [info] - testTheStringLength(Jimmy Buffet,12) [info] handed: : overall 2, Failed zero, blunders zero, handed 2, Skipped zero [success] overall time: 1 s, accomplished Dec 27, 2011 3:08:48 PM in fact, what reliable is a try out for those who can’t tag for filtering reasons? In TestNG, tagging is named teams, and teams should be leveraged besides ScalaTest to incorporate the teams in a attempt and run as though they have been tags.

Rated 4.58 of 5 – based on 12 votes