Wednesday, May 11, 2016

Test-Driven Development with N4JS

The N4JS IDE validates and checks code as you type, making it a powerful tool for writing type safe applications that that are predictable, reliable and easily maintainable over time. This means that problem-solving takes place before code is deployed and your applications are safely exported.

As test-driven development is a key technique for the development of large-scale projects, the N4JS IDE is bundled with a robust test framework called Mangelhaft. Mangelhaft is an xUnit-like framework with an engine for executing tests and will report results to the IDE while running test suites.

Testing with Mangelhaft in the N4JS IDE 

While Node.js projects written with N4JS can easily be checked and tested with Mangelhaft within the IDE, the release of Mangelhaft on npm means that your Node.js projects will stay stable when deployed on a Continuous Integration server.

Using Mangelhaft with Travis CI

Using the example project bundled with the N4JS IDE, we can demonstrate how to use Mangelhaft with a Travis build. In the Travis .yml file, we define the language of the build as node_js. Currently, Java8 must also be installed as a requirement for the build:

    sudo: required
    language: node_js
      - sudo apt-get -qq update
      - sudo apt-get install -y oracle-java8-set-default
      - "5"
      - mongodb

Mangelhaft can either be installed globally ( npm install -g n4js-node-mangelhaft ) or integrated with a build by including Mangelhaft in the devDependencies of a project and exporting as an npm package. Mangelhaft will be downloaded and installed automatically when the Travis build begins:

Installing Mangelhaft on Travis CI Server

Default test scripts described in the package.json can then be run with the npm test command which calls n4js-mangelhaft.

Test results in Travis CI

A full list of available options can be listed with the command n4js-mangelhaft -h

Using Mangelhaft with Jenkins

Mangelhaft can also be integrated with a Jenkins job and fully supports detailed xUnit test results. View the status of your tests over time with the Jenkins UI and benefit from individual test reports:

n4js-mangelhaft \
      --xunitReportFile ./build/tasks-test-report.xml \
      --xunitReportName tasks-test-report \
      --xunitReportPackage n4js.example.tasks.tests \
Mangelhaft Test Results in Jenkins UI 
Mangelhaft Test Results in Jenkins UI

Generate comprehensive xUnit test data as frequently as required and drill down to the root of any issues that arise:

Individual Test Results in a Jenkins Build

Type Safe Workflow with Mangelhaft

Running npm tests with Mangelhaft ensures Node.js projects created with N4JS stay stable with errors detected and located quickly and easily. Download the N4JS IDE and begin creating type safe Node.js projects with the peace of mind of CI tests made possible with Mangelhaft.

Resources referred to in this post

Sunday, March 13, 2016

N4JS Goes Open Source

Today NumberFour AG announced "N4JS,  An Open-Source Language and IDE for high

N4JS is built for JavaScript developers who seek to build large-scale and maintainable server-side JavaScript as well as Java developers who want to use JavaScript with familiar tool support, early validation and other Java benefitsIt bridges the strengths of JavaScript and Java; the result is a typed JavaScript superset that is dynamic, flexible and type-safe.

N4JS Feature Highlights

The N4JS language and its IDE allow for high-quality JavaScript development of large Node.js projects. Here is a list of some of its features:
  • super set of ECMAScript 5; most of ECMAScript 2015
  • transpiles to V8-compatible ECMAScript (Node.js version 5)
  • Java-like nominal types
  • TypeScript-like structural types
  • generics similar to Java 8
  • async/await (TC39/ECMAScript proposal) with support for legacy code
  • dependency injection using annotations similar to JSR330/Google Guice
  • built-in support for testing, including xUnit-like test framework "mangelhaft"
  • Node.js support: automatically download npms, export to npm

Visit the N4JS webpage to learn more about N4JS and download the latest N4JS IDE.

N4JS for Eclipse-Developers

You are a Eclipse plugin developer looking for a high-quality Java-based ECMAScript parser.
You develop DSLs wich are to be combined with JavaScript environments?

N4JS provides an Xtext-based ECMAScript 2015 parser. The created AST and type model are based on EMF, allowing for integration with other Eclipse modeling tools. Set-up is made easy due to provided Oomph set up script.The N4JS transpiler and the IDE are Eclipse-based.

Visit the N4JS GitHub page to access the source code of the N4JS IDE and the transpiler.

The N4JS Developer Blog

In this blog, the N4JS developer team at NumberFour will write about N4JS. Topics will include

  • new features
  • explanation of existing features
  • discussion of language concepts
  • description of design and implementation of the N4JS IDE and the transpiler

We are looking forward to your feedback! You can either leave comments, post to our mailing list, create issues, or, last but not least, create pull requests!