Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Prasetya, S.W.B. (Wishnu)
t3
Commits
480de26d
Commit
480de26d
authored
Jan 06, 2018
by
ISWB Prasetya
Browse files
small improvement in the generator of junit testclass
parent
1e8dee8b
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/Sequenic/T3/Sequence/Datatype/SUITE.java
View file @
480de26d
...
...
@@ -645,12 +645,13 @@ public class SUITE implements Serializable {
PrintWriter
pw
=
new
PrintWriter
(
f
);
pw
.
write
(
"import org.junit.* ;\n"
)
;
pw
.
write
(
"import static org.junit.Assert.* ;\n"
)
;
pw
.
write
(
"import java.util.logging.Logger;\n"
)
;
pw
.
write
(
"import Sequenic.T3.* ;\n"
)
;
pw
.
write
(
"import Sequenic.T3.Sequence.Datatype.* ;\n"
)
;
pw
.
write
(
"public class "
+
testclassName
+
" {\n\n"
)
;
pw
.
write
(
" public "
+
testclassName
+
"() { }\n\n"
)
;
pw
.
write
(
" SUITE S = null ;\n"
)
;
pw
.
write
(
" SUITE_RT_info info = null ;\n\n"
)
;
pw
.
write
(
"
static
SUITE S = null ;\n"
)
;
pw
.
write
(
"
static
SUITE_RT_info info = null ;\n\n"
)
;
// test-1
pw
.
write
(
" @Test\n"
)
;
pw
.
write
(
" public void test1() throws Exception {\n"
)
;
...
...
@@ -662,13 +663,16 @@ public class SUITE implements Serializable {
+
showExcExecution
+
","
+
"true ,"
// runAll is set to true
+
regressionMode
+
","
+
"null) ;\n"
// supress violation reporting
+
"null) ;\n"
// sup
p
ress violation reporting
, else use System.err
)
;
pw
.
write
(
" assertTrue(!info.seenCrash()) ; "
);
pw
.
write
(
" boolean verdict = !info.seenCrash() ;\n"
);
pw
.
write
(
" if (verdict) Logger.getLogger(CONSTANTS.T3loggerName).info(\"PASS\") ;\n"
)
;
pw
.
write
(
" else Logger.getLogger(CONSTANTS.T3loggerName).info(\"FAIL\") ;\n"
)
;
pw
.
write
(
" assertTrue(verdict) ;\n"
);
pw
.
write
(
" }\n\n"
)
;
// test-2
pw
.
write
(
" @Test\n"
)
;
pw
.
write
(
" public void test
2
() throws Exception {\n"
)
;
pw
.
write
(
" public void test
ExceptionTypeOnly
() throws Exception {\n"
)
;
pw
.
write
(
" if (S==null) S = SUITE.load(\""
+
traceFile
+
"\") ;\n"
)
;
pw
.
write
(
" Pool pool = new Pool() ;\n"
)
;
pw
.
write
(
" if (info==null) info = S.exec(pool,getClass().getClassLoader(),null,"
...
...
@@ -677,25 +681,30 @@ public class SUITE implements Serializable {
+
showExcExecution
+
","
+
"true ,"
// runAll is set to true
+
regressionMode
+
","
+
"null) ;\n"
// supress violation reporting
+
"null) ;\n"
// sup
p
ress violation reporting
, else use System.err
)
;
pw
.
write
(
" assertTrue(info.inconsistentExc.isEmpty()) ; "
);
pw
.
write
(
" boolean verdict = info.inconsistentExc.isEmpty() ;\n"
);
pw
.
write
(
" if (verdict) Logger.getLogger(CONSTANTS.T3loggerName).info(\"PASS\") ;\n"
)
;
pw
.
write
(
" else Logger.getLogger(CONSTANTS.T3loggerName).info(\"FAIL\") ;\n"
)
;
pw
.
write
(
" assertTrue(verdict) ;\n"
);
pw
.
write
(
" }\n\n"
)
;
// test-3
pw
.
write
(
" @Test\n"
)
;
pw
.
write
(
" public void test
3
() throws Exception {\n"
)
;
pw
.
write
(
" public void test
AllOracles
() throws Exception {\n"
)
;
pw
.
write
(
" if (S==null) S = SUITE.load(\""
+
traceFile
+
"\") ;\n"
)
;
pw
.
write
(
" Pool pool = new Pool() ;\n"
)
;
pw
.
write
(
" SUITE_RT_info info2 = info ;\n"
)
;
pw
.
write
(
" if (info2==null) info2 = S.exec(pool,getClass().getClassLoader(),null,"
pw
.
write
(
" if (info==null) info = S.exec(pool,getClass().getClassLoader(),null,"
+
showLength
+
","
+
showDepth
+
","
+
showExcExecution
+
","
+
"
fals
e ,"
// don't run all, stop at first violation
+
"
tru
e ,"
// don't run all, stop at first violation
+
regressionMode
+
","
+
"
System.err
) ;\n"
//
violating trace will be shown to
System.err
+
"
null
) ;\n"
//
suppress violation reporting, else use
System.err
)
;
pw
.
write
(
" assertTrue(info2.violating.isEmpty()) ; "
);
pw
.
write
(
" boolean verdict = info.violating.isEmpty() ;\n"
);
pw
.
write
(
" if (verdict) Logger.getLogger(CONSTANTS.T3loggerName).info(\"PASS\") ;\n"
)
;
pw
.
write
(
" else Logger.getLogger(CONSTANTS.T3loggerName).info(\"FAIL\") ;\n"
)
;
pw
.
write
(
" assertTrue(verdict) ;\n"
);
pw
.
write
(
" }\n"
)
;
pw
.
write
(
"}"
)
;
pw
.
flush
();
pw
.
close
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment