-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
executable file
·234 lines (220 loc) · 9.04 KB
/
index.html
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script src="js/codemirror.js" type="text/javascript"></script>
<title>PairWise Test Case Tool - powered by PICT and CodeMirror</title>
<link rel="stylesheet" type="text/css" href="css/docs.css"/>
<style type="text/css">
.CodeMirror-line-numbers {
width: 2.2em;
color: #aaa;
background-color: #eee;
text-align: right;
padding-right: .3em;
font-size: 7pt;
font-family: verdana;
padding-top: .4em;
}
select {font-family: verdana; font-size: 7pt; font-weight: 500;}
input {font-family: verdana; font-size: 7pt; font-weight: 500;}
textarea {font-family: verdana; font-size: 7pt; font-weight: 500;}
</style>
</head>
<body style="padding: 9px;" bgcolor="#DE7008">
<center><font face="verdana" size="3">PairWise Test Case Tool - powered by PICT and CodeMirror</font></center>
<div id="inputOptions">
<table width="250" border="0" cellspacing="2" cellpadding="0" bgcolor="#DE7008">
<tr>
<td width="50">
<font face="verdana" size="1"><b>Test Case Model </b></font>
</td>
<td>
<input type="button" value="CleanEditor" onclick="cleanInput()" title="Clean editor"/>
</td>
<td>
<input type="text" id="programPath" size="30" title="Path to PICT.exe" value="c:\Progra~2\PICT\PICT.exe" onchange="reloadHelpPath()" />
</td>
<td>
<input type="text" id="modelFile" size="30" title="Test Case Model file" value="C:\code\MyTestCaseModel.txt"/>
</td>
<td>
<font face="verdana" size="1"><b> Options </b></font>
</td>
<td>
<input type="text" id="pictOptions" size="30"
title="/o:N - Order of combinations (default: 2)
/d:C - Separator for values (default: ,)
/a:C - Separator for aliases (default: |)
/n:C - Negative value prefix (default: ~)
/e:file - File with seeding rows
/r[:N] - Randomize generation, N - seed
/c - Case-sensitive model evaluation
/s " value="/c"/>
</td>
<td>
<a href="LICENSE.txt" target="_blank"><font face="verdana" size="1">License</font></a>
</td>
<td>
<a href="RELEASE_NOTES.txt" target="_blank"><font face="verdana" size="1">Release Notes</font></a>
</td>
<td id="pictHelp">
<a href="C:\Progra~2\PICT\PICTHelp.htm" target="_blank"><font face="verdana" size="1">PICT user guide</font></a>
</td>
</tr>
</table>
</div>
<div id="req" style="border: 1px solid black; padding: 0px;">
<textarea id="input" cols="120" rows="35">
# ********************************************************************************************
# * GUI shell for PICT - deluxe version *
# * by Stefan Thelenius (http://abouttesting.blogspot.com/) *
# * Credits to Jacek Czerwonka (Microsoft) for PICT.exe and Marijn Haverbeke for CodeMirror *
# ********************************************************************************************
# 1. Define parameters and values
MyParameter: Yes, No, N/A
AnotherParameter: True, False
# 2. Add constraints
IF [MyParameter] = "Yes"
THEN [AnotherParameter] <> "False";
# 3. Press button GenerateTestCases
</textarea>
</div>
<table width="250" border="0" cellspacing="2" cellpadding="0" bgcolor="#DE7008">
<tr>
<td>
<font face="verdana" size="1"><b>Test Cases </b></font>
</td>
<td>
<input type="button" value="GenerateTestCases" onclick="generateTestCases()" title="Generate Test Cases"/>
</td>
<td>
<input type="text" id="testCaseOutPut" size="30" title="Test Case Output file" value="C:\code\MyTestCases.txt"/>
</td>
<td>
<input type="button" value="ExportToExcel" onclick="XLExport()" title="Export to Microsoft Excel"/>
</td>
<td>
<font face="verdana" size="1"><b> Timeout </b></font>
</td>
<td>
<input type="text" id="timeout" size="2" title="Timeout in seconds" value="5"/>
</td>
</tr>
</table>
<div id="testCaseGrid"></div>
<script type="text/javascript">
//Global var
try {
var editor = CodeMirror.fromTextArea('input', {
height: "300px",
parserfile: "pict.js",
stylesheet: "css/pictcolors.css",
path: "js/",
continuousScanning: 500,
lineNumbers: false
});
editor.focus();
}
catch (err) {
//var reload = setTimeout("window.location.reload();", 200);
}
reloadHelpPath();
function reloadHelpPath() {
document.getElementById("pictHelp").innerHTML = getPICTHelpFilePath();
}
function getPICTHelpFilePath() {
var programPath = document.getElementById("programPath").value;
var pictPath = programPath.replace('PICT.exe', 'PICTHelp.htm');
return ' <a href="' + pictPath + '" target="_blank"><font face="verdana" size="1">PICT user guide</font></a> ';
}
function cleanInput() {
editor.setCode('');
}
function readTestCaseOutFile() {
var fso = new ActiveXObject("Scripting.FileSystemObject");
var ForReading = 1
var testCaseOutPut = document.getElementById("testCaseOutPut").value;
var fh = fso.OpenTextFile(testCaseOutPut, ForReading, false);
var count = 0;
var str = '';
var strhtml = '<table border="1" cellspacing="2" cellpadding="2" bgcolor="White" id="iList">';
var parameters = new Array();
while (!fh.AtEndOfStream) {
str = fh.ReadLine();
strhtml += '<tr>';
if (count == 0) {
parameters = str.split('\t');
strhtml += '<td><b><font face="verdana" size="1">#</font></b></td>';
for (i = 0; i <= parameters.length - 1; i++) {
strhtml += '<td><b><font face="verdana" size="1">' + parameters[i] + '</font></b></td>';
}
strhtml += '<td><b><font face="verdana" size="1">Notes</font></b></td>';
}
else {
parameters = str.split('\t');
strhtml += '<td align="center"><font face="verdana" size="1">' + count + '</font></td>';
for (i = 0; i <= parameters.length - 1; i++) {
strhtml += '<td><font face="verdana" size="1">' + parameters[i] + '</font></td>';
}
strhtml += '<td><font face="verdana" size="1"> </font></td>';
strhtml += '</tr>';
}
count++;
}
strhtml += '</font></table>';
fh.Close();
if (parameters.length == 0) {
document.getElementById("testCaseGrid").innerHTML = '<font face="verdana" size="1" style="BACKGROUND-COLOR: red">Error creating test case file, please check input syntax or options...</font>'; ;
}
else {
document.getElementById("testCaseGrid").innerHTML = strhtml;
}
}
function generateTestCases() {
var inputCode = editor.getCode();
var modelFile = document.getElementById("modelFile").value;
// Create PICT temporary input file
writeFile(modelFile, inputCode);
var programPath = document.getElementById("programPath").value;
var testCaseOutPut = document.getElementById("testCaseOutPut").value;
var pictOptions = ''; // Assign data type to string
pictOptions = document.getElementById("pictOptions").value;
// Generate PICT output file
var command = 'cmd /K "' + programPath + ' ' + modelFile + ' > ' + testCaseOutPut + ' ' + pictOptions + '"';
var WshShell = new ActiveXObject("WScript.Shell");
var oExec = WshShell.Exec(command);
oExec = null;
WshShell = null;
var timeout = document.getElementById("timeout").value;
timeout = timeout * 1000;
setTimeout('readTestCaseOutFile()', timeout);
document.getElementById("testCaseGrid").innerHTML = '<font face="verdana" size="1" style="BACKGROUND-COLOR: yellow">Please wait while creating test case file...</font>';
}
function writeFile(fileName, text) {
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fh = fso.CreateTextFile(fileName, true);
fh.WriteLine(text);
fh.Close();
}
function XLExport() {
var i;
var j;
var mycell;
var tableID = "iList";
var objXL = new ActiveXObject("Excel.Application");
var objWB = objXL.Workbooks.Add();
var objWS = objWB.ActiveSheet;
for (i = 0; i < document.getElementById(tableID).rows.length; i++) {
for (j = 0; j < document.getElementById(tableID).rows(i).cells.length; j++) {
mycell = document.getElementById(tableID).rows(i).cells(j)
objWS.Cells(i + 1, j + 1).Value = mycell.innerText;
}
}
objWS.Rows(1).Font.Bold = true;
objWS.Range("A1", "Z1").EntireColumn.AutoFit();
objXL.Visible = true;
}
</script>
</body>
</html>