added unit test example tutorial

Change-Id: I71fcc4cb2c5f2623c24eceb4744ebaace0e5bd75
diff --git a/JavaScript Unit Testing Tutorial/.project b/JavaScript Unit Testing Tutorial/.project
new file mode 100644
index 0000000..69fa1c1
--- /dev/null
+++ b/JavaScript Unit Testing Tutorial/.project
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<projectDescription>

+	<name>JavaScript Unit Testing Tutorial</name>

+	<comment></comment>

+	<projects>

+	</projects>

+	<buildSpec>

+	</buildSpec>

+	<natures>

+	</natures>

+</projectDescription>

diff --git a/JavaScript Unit Testing Tutorial/Tests/Advanced/01 Long Running Tests.js b/JavaScript Unit Testing Tutorial/Tests/Advanced/01 Long Running Tests.js
new file mode 100644
index 0000000..40c9a74
--- /dev/null
+++ b/JavaScript Unit Testing Tutorial/Tests/Advanced/01 Long Running Tests.js
@@ -0,0 +1,24 @@
+/*******************************************************************************

+ * Copyright (c) 2015 Christian Pontesegger and others.

+ * All rights reserved. This program and the accompanying materials

+ * are made available under the terms of the Eclipse Public License v1.0

+ * which accompanies this distribution, and is available at

+ * http://www.eclipse.org/legal/epl-v10.html

+ *

+ * Contributors:

+ *     Christian Pontesegger - initial API and implementation

+ *******************************************************************************/

+

+function sleep(milliSeconds) {

+	end = java.lang.System.currentTimeMillis() + milliSeconds;

+	while (java.lang.System.currentTimeMillis() < end)

+		;

+}

+

+// loop over a test parameter

+for ( var cycle = 1; cycle < 10; cycle++) {

+	startTest("cycle " + cycle, "valid test");

+	sleep(500);

+	endTest();

+}

+

diff --git a/JavaScript Unit Testing Tutorial/Tests/Advanced/02 No test cases.js b/JavaScript Unit Testing Tutorial/Tests/Advanced/02 No test cases.js
new file mode 100644
index 0000000..4515e48
--- /dev/null
+++ b/JavaScript Unit Testing Tutorial/Tests/Advanced/02 No test cases.js
@@ -0,0 +1,19 @@
+/*******************************************************************************

+ * Copyright (c) 2015 Christian Pontesegger and others.

+ * All rights reserved. This program and the accompanying materials

+ * are made available under the terms of the Eclipse Public License v1.0

+ * which accompanies this distribution, and is available at

+ * http://www.eclipse.org/legal/epl-v10.html

+ *

+ * Contributors:

+ *     Christian Pontesegger - initial API and implementation

+ *******************************************************************************/

+

+// you are not required to use test cases; they simply help to structure your test results

+

+assertEquals(3, 2+1);

+assertTrue(true);

+

+throw new Packages.java.lang.NullPointerException("Not handled");

+

+// nothing executed beyond this point
\ No newline at end of file
diff --git a/JavaScript Unit Testing Tutorial/Tests/Advanced/03 Test Metadata.js b/JavaScript Unit Testing Tutorial/Tests/Advanced/03 Test Metadata.js
new file mode 100644
index 0000000..40567cc
--- /dev/null
+++ b/JavaScript Unit Testing Tutorial/Tests/Advanced/03 Test Metadata.js
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Christian Pontesegger and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Christian Pontesegger - initial API and implementation
+ *******************************************************************************/
+
+addMetaData("author", "Christian Pontesegger");
+addMetaData("license", "EPL v1.0");
+
+// starts a simple test
+startTest("empty", "an empty test case");
+addMetaData("info", "this test does nothing")
+endTest();
diff --git a/JavaScript Unit Testing Tutorial/Tests/Advanced/04 Variables.js b/JavaScript Unit Testing Tutorial/Tests/Advanced/04 Variables.js
new file mode 100644
index 0000000..d6677ab
--- /dev/null
+++ b/JavaScript Unit Testing Tutorial/Tests/Advanced/04 Variables.js
@@ -0,0 +1,19 @@
+/*******************************************************************************

+ * Copyright (c) 2015 Christian Pontesegger and others.

+ * All rights reserved. This program and the accompanying materials

+ * are made available under the terms of the Eclipse Public License v1.0

+ * which accompanies this distribution, and is available at

+ * http://www.eclipse.org/legal/epl-v10.html

+ *

+ * Contributors:

+ *     Christian Pontesegger - initial API and implementation

+ *******************************************************************************/

+

+print("Running tests on " + testDevice);

+

+// loop over a test parameter

+for ( var cycle = 1; cycle <= testCounter; cycle++) {

+	startTest("cycle " + cycle, "valid test");

+	endTest();

+}

+

diff --git a/JavaScript Unit Testing Tutorial/Tests/Simple/01 Valid tests.js b/JavaScript Unit Testing Tutorial/Tests/Simple/01 Valid tests.js
new file mode 100644
index 0000000..85708a7
--- /dev/null
+++ b/JavaScript Unit Testing Tutorial/Tests/Simple/01 Valid tests.js
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Christian Pontesegger and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Christian Pontesegger - initial API and implementation
+ *******************************************************************************/
+
+// starts a simple test
+startTest("empty", "an empty test case");
+// ends a test
+endTest();
+
+// start another test
+startTest("no test code", "a test containing no assertions");
+print("Hi from valid test");
+endTest();
+
+// third test
+startTest("valid assertions", "a test containing valid assertions");
+// check
+assertTrue(true);
+endTest();
+
+// code outside of a testcase
+print('"' + getTestFile() + '" completed');
diff --git a/JavaScript Unit Testing Tutorial/Tests/Simple/02 Test errors.js b/JavaScript Unit Testing Tutorial/Tests/Simple/02 Test errors.js
new file mode 100644
index 0000000..8340d73
--- /dev/null
+++ b/JavaScript Unit Testing Tutorial/Tests/Simple/02 Test errors.js
@@ -0,0 +1,30 @@
+/*******************************************************************************

+ * Copyright (c) 2015 Christian Pontesegger and others.

+ * All rights reserved. This program and the accompanying materials

+ * are made available under the terms of the Eclipse Public License v1.0

+ * which accompanies this distribution, and is available at

+ * http://www.eclipse.org/legal/epl-v10.html

+ *

+ * Contributors:

+ *     Christian Pontesegger - initial API and implementation

+ *******************************************************************************/

+

+// test containing assertions that fail

+startTest("invalid assertions", "a test containing invalid assertions");

+assertTrue(true);

+assertTrue(false);

+assertFalse(true);

+assertFalse(false);

+endTest();

+

+// manually create a failure

+startTest("failure", "test throwing a failure");

+failure("test broken, stop execution here");

+

+// an exception would also create a failure

+throw new java.lang.Exception("code exception");

+endTest();

+

+startTest("never to be reached");

+// not being reached as the failure above terminates test file execution

+endTest();

diff --git a/JavaScript Unit Testing Tutorial/Testsuite.suite b/JavaScript Unit Testing Tutorial/Testsuite.suite
new file mode 100644
index 0000000..07691d7
--- /dev/null
+++ b/JavaScript Unit Testing Tutorial/Testsuite.suite
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<testsuite>
+<testfiles>
+<testfile>project://Tests/Simple/02 Test errors.js</testfile>
+<testfile>project://Tests/Advanced/01 Long Running Tests.js</testfile>
+<testfile>project://Tests/Simple/01 Valid tests.js</testfile>
+<testfile>project://Tests/Advanced/02 No test cases.js</testfile>
+<testfile>project://Tests/Advanced/04 Variables.js</testfile>
+<testfile>project://Tests/Advanced/03 Test Metadata.js</testfile>
+</testfiles>
+<variables>
+<variable description="Amount of test loops for Tests/Advanced/04 Variables." name="testCounter">5</variable>
+<variable description="Identifier of test hardware" name="testDevice">&quot;Magic Hardware&quot;</variable>
+</variables>
+<codeFragments>
+<codeFragment name="TestSuite Teardown">print(&quot;Test suite finished.&quot;);</codeFragment>
+<codeFragment name="TestSuite Setup">print(&quot;Test suite started...&quot;);</codeFragment>
+</codeFragments>
+<flags/>
+<description></description>
+</testsuite>
\ No newline at end of file