找到你要的答案

Q:How to define test task

Q:如何定义测试任务

I am using VS Code to develop a simple project. I've created some unit tests (xUnit.net) and I would like create a test task to execute them. The idea is to run tests whenever I hit Ctrl+Shift+T.

However, I am not able to figure out how to define test tasks. What is the correct way to achieve that?

我使用VS代码开发一个简单的项目。我创建了一些单元测试(xUnit。net),我想创建一个测试任务的执行。这个想法是运行测试,每当我按Ctrl + Shift + T。

但是,我不知道如何定义测试任务。实现这一目标的正确方法是什么?

answer1: 回答1:

Besides naming the task to execute test you can set the isTestCommand property to true. Something like

{
   ...
   tasks: [{
      "taskName": "myTestTask",
      "isTestCommand": true,
      ...
   }]
}

This will also bind myTestTask to Ctrl+Shift+T

除了命名任务执行测试可以设置istestcommand属性设置为true。像

{
   ...
   tasks: [{
      "taskName": "myTestTask",
      "isTestCommand": true,
      ...
   }]
}

这也将mytesttask为Ctrl + Shift + T

answer2: 回答2:

Looks like they changed the default behavior of the ctrl+shfit+t keybinding in recent versions to reopen the last tab closed (like many browsers support). To view your current Keyboard Bindings, select the following menu option:

File > Preferences > Keyboard Shortcuts

If you want to change the ctrl+shfit+t keybinding back to issuing your default test task, simply change the value of the command property in the following object:

{ "key": "ctrl+shift+t", "command": "workbench.action.reopenClosedEditor" }

to be: workbench.action.tasks.test, or you can assign the testing task to a different keybinding by adding the following line to your Default Keyboard Shortcuts config file:

{ "key": "<your keybinding here>", "command": "workbench.action.tasks.test" }

他们好像改变了Ctrl键+ T键绑定在最近的版本中的默认行为来重新上选项卡关闭(像许多浏览器都支持)。若要查看当前键盘绑定,请选择下列菜单选项:

文件& gt;偏好>;键盘快捷键

如果你想按Ctrl + T键+快捷键变回发行默认的测试任务,只需改变以下对象的命令属性的值:

{ "key": "ctrl+shift+t", "command": "workbench.action.reopenClosedEditor" }

要:workbench.action.tasks.test,或您可以将测试任务不同的快捷键以下行添加到您的默认键盘快捷键配置文件:

{ "key": "<your keybinding here>", "command": "workbench.action.tasks.test" }
answer3: 回答3:

See this link it's self explanatory

https://code.visualstudio.com/Docs/editor/tasks

Create a tasks.json file inside .vscode

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "0.1.0",
    "command": "MY-COMMAND-FOR-RUNNING-TEST",
    "isShellCommand": true,
    "showOutput": "always"
}

if you have configured npm test

    {
        "taskName": "build",
        "command": "npm",
        "args": ["test"],
        "isShellCommand": true
    }

if you have configured gulp with a test task

    {
        "taskName": "build",
        "command": "gulp",
        "args": ["test"],
        "isShellCommand": true
    }

看到这个链接它的自我解释

https://code.visualstudio.com/docs/editor/tasks

创建一个tasks.json文件里面。vscode

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "0.1.0",
    "command": "MY-COMMAND-FOR-RUNNING-TEST",
    "isShellCommand": true,
    "showOutput": "always"
}

如果你已经配置了NPM的测试

    {
        "taskName": "build",
        "command": "npm",
        "args": ["test"],
        "isShellCommand": true
    }

如果你已经配置了一个测试任务的大口

    {
        "taskName": "build",
        "command": "gulp",
        "args": ["test"],
        "isShellCommand": true
    }
vscode