running, tests passing (#7)

This commit is contained in:
Lars Hvam
2021-11-25 09:38:50 +01:00
committed by GitHub
parent 265f7a07e3
commit 94a1e2392c
21 changed files with 292 additions and 101 deletions

View File

@@ -1,12 +0,0 @@
CLASS zcl_hello_world DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.
ENDCLASS.
CLASS zcl_hello_world IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
out->write( 'Hello, World' ).
ENDMETHOD.
ENDCLASS.

View File

@@ -1,30 +0,0 @@
CLASS ltcl_hello_world DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT FINAL.
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun_out.
PRIVATE SECTION.
METHODS test FOR TESTING RAISING cx_static_check.
DATA text TYPE string.
ENDCLASS.
CLASS ltcl_hello_world IMPLEMENTATION.
METHOD test.
CAST if_oo_adt_classrun( NEW zcl_hello_world( ) )->main( me ).
cl_abap_unit_assert=>assert_equals(
act = if_oo_adt_classrun_out~get( )
exp = 'Hello, World' ).
ENDMETHOD.
METHOD if_oo_adt_classrun_out~write.
text = data.
ENDMETHOD.
METHOD if_oo_adt_classrun_out~get.
output = text.
ENDMETHOD.
ENDCLASS.

View File

@@ -1,12 +0,0 @@
CLASS zcl_simple DEFINITION PUBLIC.
PUBLIC SECTION.
METHODS run RETURNING VALUE(res) TYPE i.
ENDCLASS.
CLASS zcl_simple IMPLEMENTATION.
METHOD run.
res = 3.
ENDMETHOD.
ENDCLASS.

View File

@@ -1,18 +0,0 @@
CLASS ltcl_simple DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT FINAL.
PRIVATE SECTION.
METHODS test FOR TESTING RAISING cx_static_check.
ENDCLASS.
CLASS ltcl_simple IMPLEMENTATION.
METHOD test.
DATA simple TYPE REF TO zcl_simple.
CREATE OBJECT simple.
cl_abap_unit_assert=>assert_equals(
act = simple->run( )
exp = 3 ).
ENDMETHOD.
ENDCLASS.

View File

@@ -1,16 +1,59 @@
import { spawnSync } from 'child_process'
import { join, resolve } from 'path'
import { spawnSync } from 'child_process';
import { join, resolve } from 'path';
import {expect} from "chai";
import * as fs from "fs";
const root = resolve(__dirname, '../..');
const fixtures = resolve(root, 'test', 'fixtures');
const fixtures = resolve(root, 'tests');
const bin = resolve(root, 'bin');
const run = resolve(bin, 'run.sh');
const output = join(root, 'output');
const outputFile = join(output, "results.json");
function readResult(): any {
return JSON.parse(fs.readFileSync(outputFile, "utf-8"));
}
function checkExpected(expectedFile: string): void {
const exp = fs.readFileSync(expectedFile, "utf-8");
const act = fs.readFileSync(outputFile, "utf-8");
expect(act).to.equal(exp);
}
describe('abap-test-runner', async () => {
it('simple, pass', async () => {
const slug = "simple";
const path = join(fixtures, slug, 'pass');
const output = join(root, 'output');
const slug = "simple-pass";
const path = join(fixtures, slug);
const res = spawnSync('bash', [run, slug, path, output], {cwd: root});
expect(res.status).to.equal(0);
expect(readResult().status).to.equal("pass");
checkExpected(join(path, "expected_results.json"));
});
it('simple, fail', async () => {
const slug = "simple-fail";
const path = join(fixtures, slug);
const res = spawnSync('bash', [run, slug, path, output], {cwd: root});
expect(res.status).to.equal(0);
expect(readResult().status).to.equal("fail");
checkExpected(join(path, "expected_results.json"));
});
it('simple, syntax error', async () => {
const slug = "simple-error";
const path = join(fixtures, slug);
const res = spawnSync('bash', [run, slug, path, output], {cwd: root});
expect(res.status).to.equal(0);
expect(readResult().status).to.equal("error");
checkExpected(join(path, "expected_results.json"));
});
it('hello-world, pass', async () => {
const slug = "hello-world-pass";
const path = join(fixtures, slug);
const res = spawnSync('bash', [run, slug, path, output], {cwd: root});
expect(res.status).to.equal(0);
expect(readResult().status).to.equal("pass");
checkExpected(join(path, "expected_results.json"));
});
});