Skip to content
Permalink
Browse files

Fixing PhpUnit Templates, separating Assertion and Initialization of …

…TestCase code in separate template files
  • Loading branch information...
SultanEid committed Jul 31, 2018
1 parent c1323d2 commit 8976ee3ac50412ab19c374d21ea8892dab1eb82f
@@ -1,10 +1,9 @@

class UmpleTestToPhpUnit {

assertion_true <<!<</*assertion_true*/>>
AssertTrue...
!>>
class UmpleTToPhpUnit{

assertion_true <<!<</*assertion_true*/>><<#

#>>assertTrueSomeCode <<#
#>>!>>

}
@@ -1,39 +1,30 @@

class UmpleTToPhpUnit {

members_AllAssertions <<!<</*members_AllAssertions*/>><<#


if(as.getType().equals("true")
{#>>
AssertTrue ..
if(as.getType().equals("AssertTrue"))
{
#>>
$this->assertTrue(<<=as.getAssertCode()>>);
<<#}

if(as.getType().equals("false")
if(as.getType().equals("AssertFalse"))
{#>>
AssertFalse ..
<<#}
$this->assertFalse(<<=as.getAssertCode()>>);<<#}

if(as.getType().equals("equal")
if(as.getType().equals("AssertEqual"))
{#>>
AssertEqual ..
<<#}
$this->assertEqual(<<=as.getAssertCode()>>);<<#}

if(as.getType().equals("null")
if(as.getType().equals("AssertNull"))
{#>>
AssertNull ..
<<#}
$this->assertNull(<<=as.getAssertCode()>>);<<#}

if(as.getType().equals("method")
if(as.getType().equals("AssertMethod"))
{#>>
AssertMethod ..
<<#}



$this->assertMethod(<<=as.getAssertCode()>>);<<#}
#>>
!>>



}
@@ -1,3 +1,7 @@
//use assertion_true.ump;
use members_AllAssertions.ump;
use testcase_init.ump;

class UmpleTToPhpUnit {

members_AllTestCases <<!<</*members_AllTestCases*/>><<#
@@ -15,16 +19,7 @@ for (TestCase tc : model.getTestSuite(0).getTestcases())
{
if (init.getLocOrder() == i )
{

String par = "";
for (Parameter pa : init.getParameters()){
par += pa.getValue()+",";
}
par = (String) par.subSequence(0, par.length()-1);

#>>
$<<=init.getObjectName()>> = new <<=init.getIdentifier()>> (<<=par>>);<<#

#>><<@UmpleTToPhpUnit.testcase_init>><<#
}


@@ -37,7 +32,7 @@ for (TestCase tc : model.getTestSuite(0).getTestcases())
{
if (act.getLocOrder() == i)
{
#>>
#>> //include Action Code if there is actions in a TestCAse
<<=act.getCode()>><<#
}

@@ -48,31 +43,11 @@ for (TestCase tc : model.getTestSuite(0).getTestcases())

if (tc.hasAssertions())
{

for (Assertion as: tc.getAssertions())
{
String assertCode = as.getAssertCode().replace(".","->");
if (as.getLocOrder() ==i)
{
if(as.getType().equals("AssertTrue"))
{#>>
$this->assertTrue (<<=assertCode>>);<<#}

if(as.getType().equals("AssertFalse"))
{#>>
$this->assertFalse (<<=assertCode>>);<<#}

if(as.getType().equals("AssertEqual"))
{#>>
$this->assertEqual (<<=assertCode>>);<<#}

if(as.getType().equals("AssertNull"))
{#>>
$this->assertNull(<<=assertCode>>);<<#}

if(as.getType().equals("AssertMethod"))
{#>>
$this->assertMethod (<<=assertCode>>);<<#}
#>><<@ UmpleTToPhpUnit.members_AllAssertions >><<#

}

@@ -82,7 +57,7 @@ for (TestCase tc : model.getTestSuite(0).getTestcases())



}//locEnd
}//locEnd

#>>
}
@@ -1,9 +1,13 @@
class UmpleTToPhpUnit{
testcase_init <<!<</*testcase_init*/>><<#
for (Initialization init : tc.getInits())
{#>>
init for testcase

<<#}
String par = "";
for (Parameter pa : init.getParameters()){
par += pa.getValue()+",";
}
par = (String) par.subSequence(0, par.length()-1);

#>>
$<<=init.getObjectName()>> = new <<=init.getIdentifier()>> (<<=par>>);<<#

#>>!>>
}
@@ -33,8 +33,10 @@ public function teardown(){
public function someTest()
{
$p1 = new Person ("John","123","someAddrss");
$this->assertTrue ($p1->getId()!=null);
$p1 = new Person ("John","123","someAddrss");
$this->assertTrue($p1->getId()!=null);
}
@@ -33,8 +33,10 @@ class AssertionTest extends UnitTestCase{

public function someTest()
{
$p1 = new Person ("John","123","someAddrss");
$this->assertTrue ($p1->getId()!=null);
$p1 = new Person ("John","123","someAddrss");
$this->assertTrue($p1->getId()!=null);


}


@@ -33,8 +33,10 @@ public function teardown(){
public function someTest()
{
$p1 = new Person ("John","123","someAddrss");
$this->assertTrue ($p1->getId()!=null);
$p1 = new Person ("John","123","someAddrss");
$this->assertTrue($p1->getId()!=null);
}
@@ -33,12 +33,14 @@ class DependTest extends UnitTestCase{

public function someTest()
{
$p1 = new Person ("John","123","someAddrss");
$this->assertTrue ($p1->getId()!=null);
$p1 = new Person ("John","123","someAddrss");
$this->assertTrue($p1->getId()!=null);


}





}
}
@@ -33,8 +33,10 @@ public function teardown(){
public function someTest()
{
$p1 = new Person ("John","123","someAddrss");
$this->assertTrue ($p1->getId()!=null);
$p1 = new Person ("John","123","someAddrss");
$this->assertTrue($p1->getId()!=null);
}
@@ -33,12 +33,14 @@ class GenerateTest extends UnitTestCase{

public function someTest()
{
$p1 = new Person ("John","123","someAddrss");
$this->assertTrue ($p1->getId()!=null);
$p1 = new Person ("John","123","someAddrss");
$this->assertTrue($p1->getId()!=null);


}





}
}
@@ -33,8 +33,10 @@ public function teardown(){
public function someTest()
{
$p1 = new Person ("John","123","someAddrss");
$this->assertTrue ($p1->getId()!=null);
$p1 = new Person ("John","123","someAddrss");
$this->assertTrue($p1->getId()!=null);
}
@@ -33,12 +33,14 @@ class SubOptionTest extends UnitTestCase{

public function someTest()
{
$p1 = new Person ("John","123","someAddrss");
$this->assertTrue ($p1->getId()!=null);
$p1 = new Person ("John","123","someAddrss");
$this->assertTrue($p1->getId()!=null);


}





}
}
@@ -33,8 +33,10 @@ public function teardown(){
public function someTest()
{
$p1 = new Person ("John","123","someAddrss");
$this->assertTrue ($p1->getId()!=null);
$p1 = new Person ("John","123","someAddrss");
$this->assertTrue($p1->getId()!=null);
}
@@ -33,8 +33,10 @@ class TestcaseTest extends UnitTestCase{

public function someTest()
{
$p1 = new Person ("John","123","someAddrss");
$this->assertTrue ($p1->getId()!=null);
$p1 = new Person ("John","123","someAddrss");
$this->assertTrue($p1->getId()!=null);


}


0 comments on commit 8976ee3

Please sign in to comment.
You can’t perform that action at this time.