getgauge / gauge-vscode

A Visual Studio Code plug-in for Gauge
https://gauge.org
MIT License
50 stars 19 forks source link

No possibility to jump to definitions from spec files #656

Closed tdauth closed 3 years ago

tdauth commented 3 years ago

Describe the bug

I have cloned and opened my Java project with VS code on Ubuntu. It uses the Gauge maven plugin as well as the gauge-java dependency. However, I do get the message "Error fetching Gauge and plugins version information." and there is no possibility to jump from Gauge files to the corresponding Java definitions, so my suspicion is that it is an issue with this plugin. My gauge binary is installed in /usr/local/bin/gauge. I have installed gauge using NPM, maybe this was the first mistake? Since the method described here: https://docsgaugeorg.readthedocs.io/en/latest/installing.html#linux did not work for me. If I use the standard Linux variant by adding the repository for Ubuntu I get a 403 forbidden error and cannot run sudo apt-get update anymore. Isn't there any Ubuntu package for:

Description:    Ubuntu 18.04.5 LTS                                                                                                                                                                                                                                             
Release:        18.04                                                                                                                                                                                                                                                          
Codename:       bionic

gauge -v has no output either.

When I run my specs using:

mvn gauge:execute -DspecsDir=specs/example.spec

it successfully builds the project but has no output. My spec looks like this:

# Specification Heading

This is an executable specification file. This file follows markdown syntax.
Every heading in this file denotes a scenario. Every bulleted point denotes a step.

To execute this specification, run
    gauge run specs

* Vowels in English language are "aeiou".

## Vowel counts in single word

tags: single word

* The word "gauge" has "3" vowels.

## Vowel counts in multiple word

This is the second scenario in this specification

Here's a step that takes a table

* Almost all words have vowels
     |Word  |Vowel Count|
     |------|-----------|
     |Gauge |3          |
     |Mingle|2          |
     |Snap  |1          |
     |GoCD  |1          |
     |Rhythm|0          |

The implementation is in "src/test/java":

import com.thoughtworks.gauge.Step;
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);
        }
    }

    @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;
    }
}

Maybe the setup of my project is wrong? I am no expert with Gauge or VS Code and I have no idea how to look for some meaningful logging or where to look if VS Code is still processing something.

Shouldn't there be some output of the Gauge scenarios? Maybe this is not an issue related to the gauge vscode plugin but maven plugin?

I also got the notification:

Unable to open 'myproject': File is a directory. from VS code. Maybe it has something to do with it. It is the name of the project's directory. VS Code also marks some dependencies as missing in the POM although the maven build was successful. Is there any possibility to rescan/rebuild the project in VS Code with maven? It seems to be loaded/parsed not properly in VS Code?!

What command(s) did you run when you found the bug?

For e.g.

mvn gauge:execute -DspecsDir=specs/example.spec

Output, stack trace or logs related to the bug

Versions

Gauge (Output of gauge -v)

No output?!

Node.js/Java/Python/.Net/Ruby version

Operating System information

Ubuntu: Linux ubuntu 5.4.0-72-generic

IDE information

vscode version 1.56.0

tdauth commented 3 years ago

Nevermind, it was the NPM installation of gauge. It works with the binary downloaded as ZIP file.

sriv commented 3 years ago

Perhaps your npm bin location is not present in PATH? Glad this is sorted though.