Browse Source

Endif bug resolved

Akash Singh 3 years ago
parent
commit
028322ab4b

+ 4 - 2
baangt/TestSteps/TestStepMaster.py

@@ -110,6 +110,9 @@ class TestStepMaster:
         # when we have an IF-condition and it's condition was not TRUE, then skip whatever comes here until we
         # reach Endif
         if not self.ifIsTrue and not self.elseIsTrue:
+            if command["Activity"].upper() == "IF":
+                self.manageNestedCondition(condition=command["Activity"].upper(), ifis=self.ifIsTrue)
+                return
             if command["Activity"].upper() != "ELSE" and command["Activity"].upper() != "ENDIF":
                 return
         if self.repeatIsTrue[-1]: # If repeat statement is active then execute this
@@ -276,8 +279,7 @@ class TestStepMaster:
                 self.manageNestedCondition(condition=lActivity)
                 logger.debug("Executing ELSE-condition")
         elif lActivity == "ENDIF":
-            self.ifIsTrue = True
-            self.elseIsTrue = False
+            self.manageNestedCondition(condition=lActivity)
         elif lActivity == "REPEAT":
             self.repeatActive += 1
             self.repeatIsTrue.append(True)

BIN
examples/CompleteBaangtWebdemo_else.xlsx


BIN
tests/0TestInput/ServiceTestInput/CompleteBaangtWebdemo_else.xlsx


BIN
tests/0TestInput/ServiceTestInput/CompleteBaangtWebdemo_else_error.xlsx


+ 8 - 0
tests/test_ServiceTest.py

@@ -257,6 +257,14 @@ def test_NestedIfElse_with_NoBrowser():
     check_output(output_file)
     os.remove(output_file)
 
+def test_NestedIfElse_with_greater_endif():
+    run_file = str(input_dir.joinpath("CompleteBaangtWebdemo_else_error.xlsx"))
+    try:
+        execute(run_file, globals_file=Path(input_dir).joinpath("globalsNoBrowser.json"))
+        assert 1 == 0
+    except BaseException:
+        assert 1 == 1
+
 def test_NestedLoops_and_repeat():
     run_file = str(input_dir.joinpath("CompleteBaangtWebdemo_nested.xlsx"))
     execute(run_file, globals_file=Path(input_dir).joinpath("globalsNoBrowser.json"))