-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgenerate-test-plan.js
75 lines (72 loc) · 2.9 KB
/
generate-test-plan.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
const fs = require('fs');
const { exec } = require('child_process');
const figures = require('figures');
const Excel = require('exceljs');
const generateTestPlan = () => {
fs.unlink('test-plan.xlsx', (err) => {
if (err) console.log(err); else console.log('test-plan.xlsx was deleted');
});
// eslint-disable-next-line no-unused-vars
exec('npx codeceptjs dry-run', async (error, stdout, stderr) => {
const book = new Excel.Workbook();
const sheet = book.addWorksheet('IntegrationTests');
const sheetMetrics = book.addWorksheet('Metrics');
sheet.font = { name: 'Courier New' };
let currentRow = 1;
let suiteCount = 1;
let testCount = 1;
let automated = 0;
let manual = 0;
sheet.getCell(`A${currentRow}`).value = 'S.NO.';
sheet.getCell(`B${currentRow}`).value = 'TEST';
sheet.getCell(`C${currentRow}`).value = 'TYPE';
sheet.getCell(`D${currentRow}`).value = 'RESULT';
sheet.getCell(`E${currentRow}`).value = 'ENV';
sheet.getCell(`F${currentRow}`).value = 'TESTED BY';
sheet.getCell(`G${currentRow}`).value = 'JIRA ID';
sheet.getRow(currentRow).font = { size: 16, bold: true };
// sheet.getRow(currentRow).fill = { type: 'mediumGray' };
currentRow += 1;
const rows = stdout.split('\n');
rows.forEach((row) => {
if (row.includes('--')) {
sheet.getCell(`A${currentRow}`).value = `SUITE ${suiteCount}`;
suiteCount += 1;
// eslint-disable-next-line prefer-destructuring
sheet.getCell(`B${currentRow}`).value = row.split('--')[0];
sheet.getRow(currentRow).font = { size: 14, italic: true };
// sheet.getRow(currentRow).fill = { type: 'lightGray' };
currentRow += 1;
}
if (row.includes(figures.checkboxOff)) {
sheet.getCell(`A${currentRow}`).value = testCount;
testCount += 1;
sheet.getCell(`B${currentRow}`).value = row;
sheet.getRow(currentRow).font = { size: 12 };
if (row.includes('@manual')) {
sheet.getCell(`C${currentRow}`).value = 'MANUAL';
manual += 1;
} else {
sheet.getCell(`C${currentRow}`).value = 'AUTOMATED';
sheet.getCell(`D${currentRow}`).value = '';
sheet.getCell(`E${currentRow}`).value = 'jenkins';
sheet.getCell(`F${currentRow}`).value = 'Jenkins';
automated += 1;
}
currentRow += 1;
}
});
// write metrics
sheetMetrics.getCell('A1').value = 'SUITES';
sheetMetrics.getCell('C1').value = suiteCount - 2;
sheetMetrics.getCell('A2').value = 'TESTS';
sheetMetrics.getCell('B2').value = 'AUTOMATED';
sheetMetrics.getCell('B3').value = 'MANUAL';
sheetMetrics.getCell('B3').value = 'TOTAL';
sheetMetrics.getCell('C2').value = automated;
sheetMetrics.getCell('C3').value = manual;
sheetMetrics.getCell('C4').value = testCount - 1;
await book.xlsx.writeFile('test-plan.xlsx');
});
};
generateTestPlan();