如何在Katalon Studio中执行基本Java代码

时间:2019-04-26 11:41:02

标签: java groovy katalon-studio

我正在尝试在Katalon Studio和Java中执行此基本程序,但O / P会显示

if (i < 12)

您能否像IntelliJ或Eclipse一样帮助我了解如何在Katalon Studio中执行或使用Java?

int i = 10;
if (i == 10) 
{ 
    // First if statement 
    if (i < 15) 
        System.out.println("i is smaller than 15"); 

    // Nested - if statement 
    // Will only be executed if statement above 
    // it is true 
    if (i < 12) 
        System.out.println("i is smaller than 12 too"); 
    else
        System.out.println("i is greater than 15"); 
}

1 个答案:

答案 0 :(得分:1)

简单:

  1. 打开Katalon Studio
  2. 添加一个新的测试用例,您可以根据需要调用它
  3. 切换到工作窗口底部附近的</> Script标签
  4. 现在您有了一个类似Eclipse的工作区,只需粘贴上面的代码(不需要main(),这是一个Groovy编辑器)
  5. 按下顶部的Run按钮,您将获得以下(或类似的)输出:
SLF4J: The requested version 1.7.16 by your slf4j binding is not compatible with [1.6]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
2019-04-26 14:00:02.294 [34mINFO [0;39m [36mc.k.katalon.core.main.TestCaseExecutor   -[0;39m [39m--------------------[0;39m
2019-04-26 14:00:02.297 [34mINFO [0;39m [36mc.k.katalon.core.main.TestCaseExecutor   -[0;39m [39mSTART Test Cases/test so[0;39m
2019-04-26 14:00:02.864 [39mDEBUG[0;39m [36mtestcase.test so                         -[0;39m [39m1: i = 10[0;39m
2019-04-26 14:00:02.866 [39mDEBUG[0;39m [36mtestcase.test so                         -[0;39m [39m2: if (i == 10)[0;39m
2019-04-26 14:00:02.868 [39mDEBUG[0;39m [36mtestcase.test so                         -[0;39m [39m1: if (i < 15)[0;39m
i is smaller than 15
2019-04-26 14:00:02.883 [39mDEBUG[0;39m [36mtestcase.test so                         -[0;39m [39m2: if (i < 12)[0;39m
i is smaller than 12 too
2019-04-26 14:00:02.886 [34mINFO [0;39m [36mc.k.katalon.core.main.TestCaseExecutor   -[0;39m [39mEND Test Cases/test so