如何在空手道中的两个或多个测试案例中从CSV文件读取数据

时间:2019-10-28 12:40:37

标签: api karate

我在csv文件中有一些testuser,我想测试这些用户的多个测试用例,并且还想在执行后设置一些标志作为状态

datadrivern.
@Test
Feature: [GET] datatesting
 Background:

    * print "hello"

  @Automation_TestCase_Id:9999
   Scenario Outline:

    * print '<token_username>' 

  @Automation_TestCase_Id:99991    
  Scenario Outline:    

    * print '<token_username>'
  Examples:    
      | read('testdata.csv') |

testdata.csv的内容:

    token_username,status

    test1

    test2

    test3

    test4

    test5

运行此代码时出现错误

   line 13:31 missing EXAMPLES at '\n  Scenario Outline:'
   18:00:38.752 [main] ERROR com.intuit.karate.core.FeatureParser - syntax error: missing EXAMPLES at '\n  Scenario Outline:'
   18:00:38.760 [main] ERROR com.intuit.karate.core.FeatureParser - not a valid feature file: src/test/java/features/datadrivern.feature - missing EXAMPLES at '\n  Scenario Outline:'
   Exception in thread "main" java.lang.RuntimeException: missing EXAMPLES at '\n  Scenario Outline:'
       at com.intuit.karate.core.FeatureParser.<init>(FeatureParser.java:150)
       at com.intuit.karate.core.FeatureParser.<init>(FeatureParser.java:126)
       at com.intuit.karate.core.FeatureParser.parse(FeatureParser.java:69)
       at com.intuit.karate.IdeUtils.exec(IdeUtils.java:61)
       at cucumber.api.cli.Main.main(Main.java:36)

如果我要删除一个测试用例并尝试运行,它会按预期运行,但是对于多个测试用例,它会给出错误消息

任何人都可以帮忙。我只需要使用csv文件。

0 个答案:

没有答案