Skip to content

wvlet/uni

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

468 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Uni Logo

Uni

Maven Central License

Essential Scala Utilities — Refined for Scala 3 with minimal dependencies.

Documentation

https://wvlet.org/uni/

Modules

Module Description
uni Core utilities: Design (DI), logging, JSON, MessagePack, Rx, HTTP client, control flow
uni-test Lightweight testing framework with cross-platform support
uni-netty Netty-based HTTP server

Cross-platform: JVM, Scala.js, and Scala Native.

Using uni

Add the dependency to your build.sbt (replace <version> with the version shown in the Maven Central badge above):

libraryDependencies += "org.wvlet.uni" %% "uni" % "<version>"

For Scala.js or Scala Native, use %%%:

libraryDependencies += "org.wvlet.uni" %%% "uni" % "<version>"

A minimal example using the logging API:

import wvlet.uni.log.LogSupport

class MyService extends LogSupport:
  def greet(name: String): String =
    info(s"Greeting ${name}")
    s"Hello, ${name}!"

@main def hello =
  val service = MyService()
  println(service.greet("World"))

See the reference docs for Design, Rx, JSON/MessagePack, HTTP, and more.

Using uni-test

uni-test is a lightweight test framework. Add it as a test dependency and register the framework:

libraryDependencies += "org.wvlet.uni" %% "uni-test" % "<version>" % Test
testFrameworks += new TestFramework("wvlet.uni.test.Framework")

For Scala.js or Scala Native projects, use %%%:

libraryDependencies += "org.wvlet.uni" %%% "uni-test" % "<version>" % Test

Write a test by extending UniTest:

import wvlet.uni.test.UniTest

class MyTest extends UniTest:
  test("addition works") {
    (1 + 1) shouldBe 2
  }

Run with sbt test. See the UniTest guide for assertions, property-based testing, and more.

License

Apache License 2.0

About

Essential utilities, refined for Scala 3 with minimal dependencies

Resources

License

Stars

Watchers

Forks

Contributors

Languages