在JBehave故事中有两种方法可以定义两个路径

问题描述 投票:0回答:1

我有一个故事,我需要提供JSON配置文件路径和工具路径,并将这两个路径传递给python脚本?

[当我尝试在工具路径旁边添加第二条路径时,它将使用路径后的所有字符串作为路径:/有没有办法在“给定”中提供两条路径?

故事看起来像

Scenario: Verify Certificate and Cipher misconfiguration

Given TestSSL tool  path 'C:\Users\Desktop\SSLTLS\testssl.sh-3.0' 
Then Certificate and Cipher check should return 0 for successful security-check

java代码

 @Given("TestSSL tool  path '$path'")
    public void get_TestSSL_path(@Named("path") String path)
    {
        try
        {
            Paths.get(path);
            toolPath = path;
        }
        catch (InvalidPathException | NullPointerException ex)
        {
        }
    }

    @Then("Certificate and Cipher check  should return 0 for successful security-check")
    public void verify_cipher_and_certificate_attributes() throws IOException, InterruptedException {

            String pythonFileName = "./scripts/python/security_misconfiguration_SSL_TLS.py";
            String fullcmdCommand = jsonpath + " " + toolPath ;
            System.out.println("Full path : " +fullcmdCommand);
            int script_result = Utilities.runPythonScript(pythonFileName, fullcmdCommand);
            Assert.assertEquals(0, script_result);
    }
java jbehave
1个回答
0
投票
  1. 您应该将step输入参数更改为Collection,例如:
@Given("TestSSL tool paths '$paths'")
public void get_TestSSL_path(@Named("paths") List<String> paths)
...

  1. 例如,用逗号分隔输入数据:
Given TestSSL tool paths 'C:\Users\Desktop\SSLTLS\testssl.sh-3.0, C:\Users\Desktop\SSLTLS\testssl.sh-4.0' 
© www.soinside.com 2019 - 2024. All rights reserved.