question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot run or debug unit tests from within VSCode 3

See original GitHub issue

I can run unit tests from the terminal with

mage/Mage.Tests % mvn '-Dtest=LicidAbilityTest' test

But I can’t use VSCode’s test runner integration to run tests. I’d like to have access to the VSCode debugger here…

Repro:

  1. Set up VSCode with Mage as specified in README.md:
// .vscode/launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "java",
            "name": "Debug (Launch) - Current File",
            "request": "launch",
            "mainClass": "${file}"
        },
        {
            "type": "java",
            "name": "Run Client",
            "request": "launch",
            "mainClass": "mage.client.MageFrame",
            "projectName": "mage-client",
            "cwd": "${workspaceFolder}/Mage.Client"
        },
        {
            "type": "java",
            "name": "Run Server",
            "request": "launch",
            "mainClass": "mage.server.Main",
            "projectName": "mage-server",
            "cwd": "${workspaceFolder}/Mage.Server"
        }
    ]
}
// .vscode/settings.json
{
    "files.exclude": {
        "**/.classpath": true,
        "**/.project": true,
        "**/.settings": true,
        "**/.factorypath": true
    },
    "java.configuration.updateBuildConfiguration": "interactive"
}
  1. Click the “Run Test” link above LicidAbilityTest. Nothing happens…
  2. View “Java Test Runner” output console, see
org.mage.test.cards.abilities.activated.LicidAbilityTest.Failed to parse the message: %ERROR  1
  1. Change MageTestPlayerBase to extend junit.framework.TestCase
  2. Rename CopyGameStatePerformanceTest.run to CopyGameStatePerformanceTest.go to avoid the name conflict and fix the build
  3. Click “Run Test” above LicidAbilityTest. Now the test runs, but it doesn’t initialize playerA and we get a NullPointerException

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
JayDi85commented, Nov 10, 2019

You don’t need to change any code. Try to research first error. It’s can be missing database files (game test needs db files). Run full tests from maven command line (it’s will create all missing db) or copy-paste db folder from \Mage.Server\db or \Mage.Client\db folder to \Mage.Tests\db (or any other folder like \Mage.\Verify\db – it’s depend on your test).

0reactions
jthemphillcommented, Nov 11, 2019

Thanks, works for me!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't run or debug unit tests - Visual Studio Feedback
I'm using Visual Studio Community Edition 15.8.1 and I can't run or debug any unit tests. Every time I'm trying to run the...
Read more >
Visual Studio - suddenly cannot debug tests - Stack Overflow
I tried to debug tests using Resharper 8 Unit Test Session window. The message in the result window was "Test wasn't run".
Read more >
Cannot debug single unit test anymore · Issue #2241 - GitHub
Assuming that the unit tests are discovered and the 'Run Test| Debug Test' links are visible, click on the Debug Test link of...
Read more >
How to Use VS Code to Debug Unit Test Cases | by Jennifer Fu
Click the following Run button on the left side panel. It presents an interface for Run and Debug. By specifying a proper configuration,...
Read more >
Using Visual Studio Code to debug Jest based unit tests
Step 3 Debugging our project · Place breakpoints in your code. · Click on the debug icon (sidebar). · Pick up from the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found