Skip to content

onux/jsppUnit

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

js++Unit

js++Unit

js++Unit is an xUnit unit testing framework for writing and running automated tests using the JS++ programming language.

The library features a very concise and familiar syntax. js++Unit was inspired by the Mocha test framework for JavaScript and other xUnit frameworks.

Getting Started

Download the ConsoleStyle library, which js++Unit depends on.

In your editor, create a test.jspp:

import Vendor.JSPPUnit;
import Vendor.JSPPUnit.Assert;

suite("Math", void() {
	test("plus", void() {
		equal( 1 + 1 , 2 );
	});
});
JSPPUnit.run();

In your terminal:

$ js++ test.jspp path/to/jsppUnit/src/ path/to/ConsoleStyle/src/

You need to link the js++Unit library and the ConsoleStyle library (which js++Unit depends on) in order to successfully compile. The best practice is to use the src folder for the libraries rather than the libraries' root directories; otherwise, there may be tests and other unwanted files fed into the compiler, and the compiler will complain there is more than one main file.

The compiler should have generated an app.jspp.js file. Run it (e.g. with Node.js) and you should see the test output:

$ node app.jspp.js
  Math

    ✔ plus

  1 passing (1ms)

Modularization

Since JS++ only allows one "main file", it is highly recommended you define your test suites using modules:

module Vendor.MyCompany.MyApp.Tests.Tests1
{
	public void queue() {
		suite("My test suite", void() {
			/* ... */
		});
	}
}

You can then execute all of your modularized tests by importing them into the main file and calling JSPPUnit.run:

import Vendor.JSPPUnit;
import Vendor.MyCompany.MyApp.Tests.Tests1;
import Vendor.MyCompany.MyApp.Tests.Tests2;

Tests1.queue();
Tests2.queue();

JSPPUnit.run();

Web Browser Output

js++Unit supports web browser output if executed inside a web browser. Simply include the compiled .jspp.js file for your tests:

<!DOCTYPE html>
<head>
<title>js++Unit Web Browser</title>
</head>
<body>
<script type="text/javascript" src="../path/to/tests_main_file.jspp.js"></script>
</body>
</html>

License

MIT License