All Projects → japgolly → Test State

japgolly / Test State

Licence: apache-2.0
Scala Test-State.

Programming Languages

scala
5932 projects
script
160 projects
scalajs
39 projects
scalaz
18 projects

Projects that are alternatives of or similar to Test State

Sup
Composable, purely functional healthchecks in Scala.
Stars: ✭ 138 (+15.97%)
Mutual labels:  cats, functional-programming, fp
Stm4cats
STM monad for cats-effect
Stars: ✭ 35 (-70.59%)
Mutual labels:  cats, functional-programming, fp
Monix
Asynchronous, Reactive Programming for Scala and Scala.js.
Stars: ✭ 1,819 (+1428.57%)
Mutual labels:  cats, functional-programming, fp
Pfps Shopping Cart
🛒 The Shopping Cart application developed in the book "Practical FP in Scala: A hands-on approach"
Stars: ✭ 262 (+120.17%)
Mutual labels:  cats, functional-programming, fp
D4s
Dynamo DB Database Done Scala-way
Stars: ✭ 27 (-77.31%)
Mutual labels:  functional-programming, fp
Es Cqrs Shopping Cart
A resilient and scalable shopping cart system designed using Event Sourcing (ES) and Command Query Responsibility Segregation (CQRS)
Stars: ✭ 19 (-84.03%)
Mutual labels:  cats, functional-programming
Flawless
WIP Delightful, purely functional testing no-framework. Don't even try to use it at work!
Stars: ✭ 33 (-72.27%)
Mutual labels:  functional-programming, fp
Funland
Type classes for interoperability of common algebraic structures in JavaScript, TypeScript and Flow
Stars: ✭ 46 (-61.34%)
Mutual labels:  functional-programming, fp
Rambda
Faster and smaller alternative to Ramda
Stars: ✭ 1,066 (+795.8%)
Mutual labels:  functional-programming, fp
Skunk
A data access library for Scala + Postgres.
Stars: ✭ 1,107 (+830.25%)
Mutual labels:  cats, functional-programming
Monocle
Optics library for Scala
Stars: ✭ 1,357 (+1040.34%)
Mutual labels:  cats, functional-programming
Frameless
Expressive types for Spark.
Stars: ✭ 717 (+502.52%)
Mutual labels:  functional-programming, fp
Funfix
Functional Programming Library for JavaScript, TypeScript and Flow ✨⚡️
Stars: ✭ 596 (+400.84%)
Mutual labels:  functional-programming, fp
Bugz
🐛 Composable User Agent Detection using Ramda
Stars: ✭ 15 (-87.39%)
Mutual labels:  functional-programming, fp
Fkit
A functional programming toolkit for JavaScript.
Stars: ✭ 588 (+394.12%)
Mutual labels:  functional-programming, fp
Bow
🏹 Bow is a cross-platform library for Typed Functional Programming in Swift
Stars: ✭ 538 (+352.1%)
Mutual labels:  functional-programming, fp
Zio Logging
Simple logging for ZIO apps, with correlation, context & pluggable backends out of the box.
Stars: ✭ 85 (-28.57%)
Mutual labels:  functional-programming, fp
Cats Stm
An STM implementation for Cats Effect
Stars: ✭ 106 (-10.92%)
Mutual labels:  cats, functional-programming
Clear Config
Scala FP configuration library with a focus on runtime clarity
Stars: ✭ 108 (-9.24%)
Mutual labels:  functional-programming, fp
Fasy
FP iterators that are both eager and asynchronous
Stars: ✭ 488 (+310.08%)
Mutual labels:  functional-programming, fp

Scala Test-State

Test stateful stuff statelessly, and reasonably.

Build Status

Contents

What is this?

Firstly, a quick mention of what this is not:

  1. This is not a test framework.
    Use it conjunction with ScalaTest, Specs2, μTest, etc.

  2. This is not a property testing library.
    Use it conjunction with ScalaCheck, Nyaya, ScalaProps, etc.

Ok, so what is this? This is a library that:

  1. Lets you write pure, immutable, referentially-transparent tests that verify stateful, effectful code or data.

  2. Encourages composability of test concepts such as invariants/properties, pre/post conditions, dynamic actions/assertions, and more.

  3. Makes test failure and inspection easy to comprehend.

Uses

  • Unit-test a webapp with Scala.JS.
  • Integration testing.
  • UAT automation.
  • Random-test (fuzz-test) like Android's monkeyrunner or ScalaCheck's Command API.
  • Data migration.

Features

  • Compiled for Scala & Scala.JS.
  • Can run synchronously, asynchronously (Future) or in your own context-type (eg IO). Is stack-safe.
  • Everything is immutable and composable.
  • Everything can be transformed into (reused in) different contexts.
  • Combines property and imperative testing.
  • Actions and assertions can be non-deterministic and/or dependent on runtime state.
  • Transparent and informative about test execution.
  • Includes an abstract DomZipper which greatly simplifies the task of HTML/SVG observation.
  • Comes with various DomZipper implementations and backends.
  • Lots of platform-specific utilities for web testing.
  • Configurable error handling. Be impure and throw exceptions or be pure and use a custom ADT to precisely maintain all forms of failure and error in your domain; it's up to you.
  • Extension modules for various 3rd-party libraries. (Scalaz, Cats, more.)

How does this work?

The key is to take observations of anything relevant in the stateful test subject. Observations are like immutable snapshots. They capture what the state was at a particular point in time. Once an observation is captured, assertions are performed on it.

Optionally, you can specify some kind of test-only state that you modify as you test, and use to ensure the real-world observations are what you expect.
For example, if you're testing a bank account app, you could maintain your own expected balance such that when you instruct the app to make a deposit, you add the same amount to your state. You could then add an invariant that whenever the balance is shown in the app, it matches the expected state balance.

This is a (simplified) model of how tests are executed:

concept

When retries are enabled, then test execution is like this.

How do I use this?

Modules

Module Description JVM JS
core The core module. JVM JS
dom-zipper Standalone utility for observing web DOM with precision with conciseness.
This is the base API; concrete implementations below.
JVM JS
dom-zipper-jsoup DOM zipper built on Jsoup. JVM
dom-zipper-selenium DOM zipper built on Selenium.
Also comes with a fast version with uses Jsoup for nearly all operations which is 5-50x faster.
See doc/SELENIUM.md.
JVM
dom-zipper-sizzle DOM zipper built on Sizzle. JS
ext-cats Extensions for Cats. JVM JS
ext-nyaya Extensions for Nyaya. JVM JS
ext-scalajs-react Extensions for scalajs-react. JS
ext-scalaz Extensions for Scalaz. JVM JS
ext-selenium Extensions for Selenium. JVM

Examples

  • Scala.Js + React - Demonstrates DomZipper, invariants, actions, basics.
  • Selenium - Demonstrates Selenium testing of external web content, using retry scheduling (instead of Thread.sleep), parallelism and concurrency.
  • [TODO] DB triggers. - real external state, ref.
  • [TODO] Mutable sample. - fuzz, invariants.

Support

If you like what I do —my OSS libraries, my contributions to other OSS libs, my programming blog— and you'd like to support me, more content, more lib maintenance, please become a patron! I do all my OSS work unpaid so showing your support will make a big difference.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].