Git Product home page Git Product logo

unit-testing-in-scala's Introduction

Unit Testing in Scala

This project uses ScalaTest to write all the unit tests in the course.

Prerequisites

  • You must have git installed
  • You must have Java v13 installed
➜ java -version
openjdk version "13" 2019-09-17
OpenJDK Runtime Environment AdoptOpenJDK (build 13+33)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 13+33, mixed mode, sharing)
  • You must have sbt 1.3.3 or higher installed
➜ sbt --version
sbt version in this project: 1.3.3
sbt script version: 1.3.3
➜ scala --version
Scala code runner version 2.13.1 -- Copyright 2002-2019, LAMP/EPFL and Lightbend, Inc.

How to run?

  • Create a fork of this repo. Follow Github documentation on how to achieve this.
  • Clone your forked repo.
git clone https://github.com/<your-user-name>/Unit-Testing-In-Scala
cd Unit-Testing-In-Scala

Verify if the project is setup for the course

sbt "runMain BankOfScala"

Module 03 - Writing the First Test

Add the scalatest dependency in build.sbt

libraryDependencies += "org.scalatest" %% "scalatest" % "3.1.0" % "test"

Compiling & Running test using Scala

scalac -classpath "*.jar" HelloWorldSpec.scala
  • Run the Test
scala -classpath "*.jar" org.scalatest.run HelloWorldSpec

Module 07 - Mocking and Tagging Your Tests

The latest ScalaMock release 4.4.0 has not been updated with the latest ScalaTest release 3.1.0. There is an open pull request to merge the changes.

However, there are no breaking or conflicting changes between ScalaTest and ScalaMock. So, in order to learn ScalaMock, you can learn it with the ScalaTest release 3.0.8 which is 1 release behind the latest ScalaTest 3.1.0.

Clone the repository

https://github.com/hhimanshu/Unit-Testing-In-Scala-Mocking

The test source is available under src/test/scala.

To run all the tests, run

test

To run the test including a specific tag, run

testOnly -- -n com.h2.tags.Fast
testOnly -- -n com.h2.tags.Slow

To run the test excluding a specific tag, run

testOnly -- -l com.h2.tags.Fast
testOnly -- -l com.h2.tags.Slow

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.