1.4.2 • Published 5 months ago

@rbxts/runit v1.4.2

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

Runit

pronounced "R Unit"

A unit testing library for Roblox heavily inspired by xUnit from C#

Example

src/scripts/run-tests.server.ts

import { TestRunner } from "@rbxts/runit";
import { ServerScriptService } from "@rbxts/services";

const testRunner = new TestRunner(
  ServerScriptService.WaitForChild("Tests")
);

testRunner.run();

src/tests/number-utility-test.ts

import { Fact, Theory, InlineData, Assert } from "@rbxts/runit";

function toNearestFiveOrTen(n: number): number {
  const nearestFive = round(n / 5) * 5;
  const lowerTen = floor(nearestFive / 10) * 10;
  const upperTen = lowerTen + 10;

  if (abs(n - lowerTen) <= abs(n - nearestFive))
    return lowerTen;
  else if (abs(n - upperTen) <= abs(n - nearestFive))
    return upperTen;

  return nearestFive;
}

class NumberUtilityTest {
  // tests one case
  @Fact
  public eightBecomesTen(): void {
    Assert.equal(10, toNearestFiveOrTen(8));
  }

  // tests multiple cases
  @Theory
  @InlineData(8, 10)
  @InlineData(14, 15)
  @InlineData(18, 20)
  @InlineData(3, 5)
  @InlineData(2, 0)
  public roundsToNearestFiveOrTen(input: number, expected: number): void {
    Assert.equal(expected, toNearestFiveOrTen(input));
  }
}

export = NumberUtilityTest;

Setup/Teardown

Setup can be done via the constructor. Teardown is done using the destroy method, which is automatically called after all tests have completed.

class MyTest {
  private readonly junk = new Junk;

  public destroy(): void {
    this.junk.destroy();
  }
}
1.4.2

5 months ago

1.4.1

5 months ago

1.4.0

5 months ago

1.3.11

5 months ago

1.3.10

5 months ago

1.3.9

5 months ago

1.3.8

5 months ago

1.3.7

6 months ago

1.3.6

7 months ago

1.3.5

7 months ago

1.3.4

7 months ago

1.3.3

7 months ago

1.3.2

7 months ago

1.3.1

8 months ago

1.3.0

8 months ago

1.2.9

8 months ago

1.2.8

8 months ago

1.2.7

8 months ago

1.2.6

8 months ago

1.2.5

8 months ago

1.2.4

8 months ago

1.2.3

10 months ago

1.2.2

10 months ago

1.2.1

10 months ago

1.2.0

10 months ago

1.1.9

10 months ago

1.1.8

10 months ago

1.1.7

10 months ago

1.1.6

10 months ago

1.1.5

10 months ago

1.1.4

10 months ago

1.1.3

10 months ago

1.1.2

11 months ago

1.1.1

11 months ago

1.1.0

11 months ago

1.0.9

11 months ago

1.0.8

11 months ago

1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago