lunarmodules / busted

Elegant Lua unit testing.
https://lunarmodules.github.io/busted/
MIT License
1.39k stars 184 forks source link

vscode has no code hints for bursted assets #647

Closed ffbh123456 closed 3 years ago

ffbh123456 commented 3 years ago

There is no code hint when writing assets test, is there any good way? For example, when I input assert.a, I hope vscode can prompt me the words are, are_not

截屏2020-11-29 21 33 21
DorianGray commented 3 years ago

We do not run busted in vscode nor was it designed to support code completion in vscode. Pull requests are welcome!

ffbh123456 commented 3 years ago

Hi, @DorianGray I wrote a simple vscode code snippet, which can quickly generate busted unit test related code, if you need it, I will push a Pull request

{
    "assert.is_true": {
        "prefix": "assert.is_true",
        "body": [
            "assert.is_true($1);"
        ],
        "description": "busted assert"
    },
    "assert.is_not_true": {
        "prefix": "assert.is_not_true",
        "body": [
            "assert.is_not_true($1);"
        ],
        "description": "busted assert"
    },
    "assert.is.equal": {
        "prefix": "assert.is.equal",
        "body": [
            "assert.is.equal($1);"
        ],
        "description": "busted assert"
    },
    "assert.is.truthy": {
        "prefix": "assert.is.truthy",
        "body": [
            "assert.is.truthy($1);"
        ],
        "description": "busted assert"
    },
    "assert.is.falsy": {
        "prefix": "assert.is.falsy",
        "body": [
            "assert.is.falsy($1);"
        ],
        "description": "busted assert"
    },
    "assert.is_not.equal": {
        "prefix": "assert.is_not.equal",
        "body": [
            "assert.is_not.equal($1);"
        ],
        "description": "busted assert"
    },
    "assert.is.errors": {
        "prefix": "assert.is.errors",
        "body": [
            "assert.is.errors(",
            "\tfunction()",
            "\t\t$1",
            "\tend",
            ")"
        ],
        "description": "busted assert"
    },
    "assert.is_not.errors": {
        "prefix": "assert.is_not.errors",
        "body": [
            "assert.is_not.errors(",
            "\tfunction()",
            "\t\t$1",
            "\tend",
            ")"
        ],
        "description": "busted assert"
    },
    "test": {
        "prefix": "test",
        "body": [
            "test(",
            "\t\"$1\",",
            "\tfunction()",
            "\t\t",
            "\tend",
            ")"
        ],
        "description": "busted assert"
    },
    "describe": {
        "prefix": "describe",
        "body": [
            "describe(",
            "\t\"$1\",",
            "\tfunction()",
            "\t\t",
            "\tend",
            ")"
        ],
        "description": "busted assert"
    }
}
截屏2020-11-30 20 41 02 截屏2020-11-30 20 41 17 截屏2020-11-30 20 41 37 截屏2020-11-30 20 41 46 截屏2020-11-30 20 43 54 截屏2020-11-30 20 44 04
alerque commented 3 years ago

These functions actually come from the luassert project. I think the correct way to get completion in your editor is to tel your code scanner to look for function definitions in that project's code as well as busted & your own local project.

I do not think code libraries should be responsible for creating completion routines for any editor, VScode or otherwise. The list would never end, and some have many different formats they would want the data in depending on the plugin you used. This should be generated by the editor/plugin somewhere feeding it the code libraries being used.

ffbh123456 commented 3 years ago

OK, I will try it later