gauge
gauge copied to clipboard
Gauge table in concept file doesn't accept |-------------| after the header.
Expected behavior
Gauge table in concept file should accept |-------------| after the header
Actual behavior
Gauge table in concept file doesn't accept |-------------| after the header
Steps to reproduce
- Create a concept file with a gauge table like below
- And the JSON Path Assertions for the response should be equal to the following
|JSON Path |Expected Result |
|------------------------------|----------------------------------------------------------------|
|$.title |Expert API Automation using MaxSoft ATA Framework |
|$.userId |osan |
|$.archived |true |
|$.book.bookTitle |Expert API Deck3 |
- Create a spec and provide the concept name as a step name
- Run that spec.
- You will get an error that |-------------| has taken as a data record.
Gauge version
Gauge version: 0.9.7
Commit Hash: bc9784c
Plugins
-------
csharp (0.10.1)
flash (0.0.1)
html-report (4.0.2)
java (0.6.6)
ruby (0.4.2)
screenshot (0.0.1)
spectacle (0.1.2)
xml-report (0.2.0)
I think this is an issue for https://github.com/getgauge/gauge itself, as the parsing of parameters/steps is a core feature and not a responsibility of the runner
@zabil Any update on this?
Can you share an example that's a valid concept and spec file? You can insert the samples as a comment.
@zabil Please look this
Concept
Date Created : 11/29/2017
Version : 1.0.0
Owner : Osanda Deshan
Description : This is a concept file with following syntax for each concept.
# Invoke PI API in Staging Environment using valid username and password and save the access token inside the text file
* Given that a user needs to invoke "Get Staging PI Token"
* And the user set the request attributes as follows
|Attribute Value In JSON Template|Attribute Value To Be Set|
|--------------------------------|-------------------------|
|#username |osa |
|#password |Password1 |
* When the user invokes the API
* Then the status code for the request is "201"
* And the JSON Path Assertions for the response should be equal to the following
|JSON Path |Expected Result|
|--------------|---------------|
|$.status |success |
* And save the access token in the response which is located inside the JSON Path of "$.data"
Spec
# Get Staging PI Token Specification
Date Created : 11/29/2017
Version : 1.0.0
Owner : Osanda Deshan
Description : This is an executable specification file which follows markdown syntax. Every heading in this file denotes a scenario. Every bulleted point denotes a step.
tags: get_pi_token, staging_token
## Invoke PI API in Staging Environment using valid username and password and save the access token inside the text file
tags: get_pi_token, staging
* Invoke PI API in Staging Environment using valid username and password and save the access token inside the text file
Screenshot
If you need to troubleshoot this issue further, I can give a sample project too.
@osandadeshan A sample project may help us debug further. I was unable to see this with my test setup.
MaxSoft-IntelliAPI-Demo.zip Please check this
@osandadeshan I can see the error too. But what seems to be weird is that the first table in your concept seems to have the correct values. The second one seems to accept the dashes as a row too. Is it possible to share the code snippet for the step with the table. I feel that it may be a implementation detail. (I don't need the whole code, just how you are using the table may be helpful).
@nehashri This is function which fires from the above step implementation
// Use this method to validate the content of the response using JSON Path Assertions
public void jsonPathAssertionEquals(Table table){
List<TableRow> rows = table.getTableRows();
List<String> columnNames = table.getColumnNames();
for (TableRow row : rows) {
if (row.getCell(columnNames.get(1)).substring(0, Math.min(row.getCell(columnNames.get(1)).length(), FILE_SYNTAX_CHARACTER_COUNT)).toLowerCase().equals(FILE_SYNTAX)) {
jsonPathAssertionEquals(row.getCell(columnNames.get(0)), TextFile.read(CURRENT_DIRECTORY + row.getCell(columnNames.get(1)).substring(FILE_SYNTAX_CHARACTER_COUNT, row.getCell(columnNames.get(1)).length()-1)));
} else {
jsonPathAssertionEquals(row.getCell(columnNames.get(0)), row.getCell(columnNames.get(1)));
}
}
}
This issues seems to be replicable when the above sample projects spec and concept file is copied over.
@nehashri Thanks for the response. Let me know when this is available in a release.
@osandadeshan You can add an empty line after table as a workaround for now.
@negiDharmendra You mean like this?
* And the JSON Path Assertions for the response should be equal to the following
|JSON Path |Expected Result|
|--------------|---------------|
|$.status |success |
* And save the access token in the response which is located inside the JSON Path of "$.data"
I'm having this issue too in Gauge 1.0.6. The workaround is not working for me though.
@negiDharmendra Is there a different workaround i can use for now?
As a workaround, I'm doing this:
foreach (var row in table.GetTableRows())
{
if (IsInvalidTableRow(row, table.GetColumnNames()[0]))
continue;
// row processing
}
private static bool IsInvalidTableRow(TableRow row, string testColumn)
{
return row.GetCell(testColumn).Contains("---");//check if gauge is sending the separator row...
}