Gauge.writeMessage are shown in console when running with plugin
haroon-sheikh opened this issue · 6 comments
If you have Gauge.writeMessage("Hello, World!")
in your steps, and when running with plugin, the message Hello, World!
is shown in console output.
We should have the ability to exclude the output.
Gauge version: 1.0.3
Plugins
-------
html-report (4.0.5)
java (0.6.9)
screenshot (0.0.1)
xml-report (0.2.0)
hi @haroon-sheikh - i am trying to simulate this, but no luck. WIth gauge (1.0.3) and gauge-java (0.6.9) - both released versions as well as the latest nightlies of the two, when I do gauge run specs
I get this:
# Specification Heading
## Vowel counts in single word ✔ ✔
## Vowel counts in multiple word ✔ ✔
Successfully generated html-report to => /tmp/foo/foo/reports/html-report/index.html
Specifications: 1 executed 1 passed 0 failed 0 skipped
Scenarios: 2 executed 2 passed 0 failed 0 skipped
Total time taken: 55ms
I think I am missing something - would be great if you can help reproduce this. Perhaps a docker image with this behaviour?
I am running this on linux.
[EDIT]: here's what my StepImplementation.java
looks like:
package foo;
import com.thoughtworks.gauge.Step;
import com.thoughtworks.gauge.Gauge;
import com.thoughtworks.gauge.Table;
import com.thoughtworks.gauge.TableRow;
import java.util.HashSet;
import static org.assertj.core.api.Assertions.assertThat;
public class StepImplementation {
private HashSet<Character> vowels;
@Step("Vowels in English language are <vowelString>.")
public void setLanguageVowels(String vowelString) {
vowels = new HashSet<>();
for (char ch : vowelString.toCharArray()) {
vowels.add(ch);
}
Gauge.writeMessage("foo");
}
@Step("The word <word> has <expectedCount> vowels.")
public void verifyVowelsCountInWord(String word, int expectedCount) {
int actualCount = countVowels(word);
assertThat(expectedCount).isEqualTo(actualCount);
}
@Step("Almost all words have vowels <wordsTable>")
public void verifyVowelsCountInMultipleWords(Table wordsTable) {
for (TableRow row : wordsTable.getTableRows()) {
String word = row.getCell("Word");
int expectedCount = Integer.parseInt(row.getCell("Vowel Count"));
int actualCount = countVowels(word);
assertThat(expectedCount).isEqualTo(actualCount);
}
}
private int countVowels(String word) {
int count = 0;
for (char ch : word.toCharArray()) {
if (vowels.contains(ch)) {
count++;
}
}
return count;
}
}
Hi @sriv, this only happens when you're using the maven plugin. i.e. mvn gauge:execute -DspecsDir=specs/test.spec
The below is from the above StepImplementation.
It does not happen via gauge-maven plugin. I think I know what's going on.
This CheckHAH
was a unintentional commit pushed by mistake and was reverted. But this was almost a year ago. See gitter chat
Now since you say you are on gauge 1.0.3
I think there might be another gauge binary somewhere that is picked up by mvn
.
Can you please check:
- does this happen on all machines?
- what does
which gauge
yield in the machines where you see this?
@sriv which gauge
returns /usr/local/bin/gauge
on my machine which is 1.0.3
but we have the same issue on running with latest and older versions inside a docker image.
@haroon-sheikh I think the issue here is not with the Gauge version but the Gauge Java plugin version.
Can you check the plugin location when you run Gauge, check if GAUGE_HOME
environment variable is set anywhere and is pointing to a different location than the default. Can you also check the gauge-java
version in your pom.xml file and see if the same version is used.
Hi @nehashri, Yes you're right, think the issue is with gauge-java:0.6.5
and when this is updated to later version, no longer console the outputs the messages.