I can't for the life of me find documentation or a tutorial for kicking off mocha unit tests in Visual Studio Online builds.
I have node.js app that is building in VSO and being deployed to Azure. That all works wonderfully. I can't seem to figure out how to kick off the spec files through the build process.
How is this done? Is there documentation available somewhere that I'm missing.
Assume you have setup Mocha tests with your package.json, i.e. you run tests with npm test. For more information, refer to https://docs.npmjs.com/cli/test.
In your Visual Studio Online build/release:
Add a "npm" task to install JUnit reporter
Run custom command install mocha-junit-reporter
Add a "npm" task
Run custom command test -- --reporter mocha-junit-reporter
Tips: You may want to increase timeout by adding --timeout 30000 because the build agent maybe running slower than your dev box
Then, add a "Publish Test Results" task
Set "Test result format" to "JUnit"
Check the box on "Continue on error"
Under "Control Options" > "Run this task", set it to "Even if a previous task has failed, unless the build was canceled"
Queue a build, you should see Mocha test results in your VSO build.
BONUS! You can also add code coverage to your Mocha run with nyc (formerly known as Istanbul)
On top of the steps above:
Install Istanbul locally to your package.json
Run npm install nyc--save-dev
Modify your scripts in package.json
Update { "scripts": { "test": "nyc --repoter=cobertura mocha" } }
Modify the "npm test" task
Run custom command test -- --reporter mocha-junit-reporter
Add a "Publish Code Coverage Results" task
Set "Code Coverage Tool" to "Cobertura"
Set "Summary File" to $(System.DefaultWorkingDirectory)/coverage/cobertura-coverage.xml
Set "Report Directory" to $(System.DefaultWorkingDirectory)/coverage/
Check the box on "Continue on error"
Under "Control Options" > "Run this task", set it to "Even if a previous task has failed, unless the build was canceled"
Add a new build variable NPM_CONFIG_COVERAGE and set it to true
Now you got both unit tests and code coverage results in your build report.
If you've configured you package.json to be able to run tests, adding a npm step that executes npm run test should do it. If you want to publish the test results you need to make sure that Mocha is writing its results to a format understood by Visual Studio Team Services. JUnit format would be a safe bet. Then follow up with a Publish test Results step that uploads the test results.
You can also use the Visual Studio Test Runner, combined with Chutzpah to run your tests, but I suppose that's going to be a lot of additional work to setup and isn't going to add much.
After quite a bit of fiddling around i got it to work by adding a "Command line task" to my build definition, i used the following parameters:
Set Tool to node
Set Arguments to $(Build.SourcesDirectory)\node_modules\jasmine-node\bin\jasmine-node --verbose test\
My tests are under a "test" folder, also make sure you have jasmine-node as a dev dependency
Related
I am developing an extension for vscode using typescript. I set up a GitHub Action which is executing my test cases. To gather the test coverage I am using nyc.
These are my node scripts:
"compile": "tsc -p ./",
"test": "npm run compile && node ./out/test/runTest.js",
"coverage": "nyc npm run test"
When I run npm run coverage I see all my test cases are getting executed (they are not stored in the file runTest.js), but only the coverage for the test file runTest.js is gathered. The relevant classes lib.ts and extension.ts are not shown in the coverage.
Why is this so? What am I doing wrong?
See my package.json and .nycrc.json for configuration.
I could fix this problem by sticking to the great blogpost which I found posted on a similar Question.
The problem is, that NYC is a command line tool. When executing the test I focused on my configuration in the .nycrc file. Fact is, that the visual studio code test runner is not using this configuration and has to be configured inside the test runner.
I fixed the broken test coverage generation inside this commit.
Despite lack of official support for Junit5 in Android Studio (as of ver 4.2.2), running unit test from within the studio, by right-clicking '(test)' folder in Project:Android tool window & choosing "Run 'Tests in...'" for example, executes both JUnit4 and 5 tests.
However, running unit test from command line by executing "gradlew test" runs only JUnit4 tests.
See sample github project which demonstrates it. For details on running tests from command line & location of report files see here.
I looked how android studio runs the tests, but it doesn't execute "gradlew test". instead, it runs gradle tasks "[:app:generateDebugSources, :app:compileDebugSources, :app:createMockableJar, :app:compileDebugUnitTestSources]" (from idea.log) and then executes java jars:
/home/grzeg/Android/android-studio/jre/bin/java -ea -Didea.test.cyclic.buffer.size=1048576 -javaagent:/home/grzeg/Android/android-studio/lib/idea_rt.jar=37775:/home/grzeg/Android/android-studio/bin -Dfile.encoding=UTF-8 -classpath /home/grzeg/Android/android-studio/lib/idea_rt.jar:/home/grzeg/.m2/repository/org/junit/platform/junit-platform-launcher/1.7.1/junit-platform-launcher-1.7.1.jar:/home/grzeg/.m2/repository/org/apiguardian/apiguardian-api/1.1.0/apiguardian-api-1.1.0.jar:/home/grzeg/.m2/repository/org/junit/platform/junit-platform-engine/1.7.1/junit-platform-engine-1.7.1.jar:/home/grzeg/.m2/repository/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar:/home/grzeg/.m2/repository/org/junit/platform/junit-platform-commons/1.7.1/junit-platform-commons-1.7.1.jar:/home/grzeg/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.7.1/junit-jupiter-engine-5.7.1.jar:/home/grzeg/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.7.1/junit-jupiter-api-5.7.1.jar:/home/grzeg/.m2/repository/org/junit/vintage/junit-vintage-engine/5.7.1/junit-vintage-engine-5.7.1.jar:/home/grzeg/.m2/repository/junit/junit/4.13/junit-4.13.jar:/home/grzeg/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:/home/grzeg/Android/android-studio/plugins/junit/lib/junit5-rt.jar:/home/grzeg/Android/android-studio/plugins/junit/lib/junit-rt.jar:/home/grzeg/Android/Sdk/platforms/android-30/data/res:/home/grzeg/Android/AndroidStudioProjects/BugReport/app/build/intermediates/javac/debug/classes:/home/grzeg/Android/AndroidStudioProjects/BugReport/app/build/intermediates/compile_and_runtime_not_namespaced_r_class_jar/debug/R.jar:/home/grzeg/Android/AndroidStudioProjects/BugReport/app/build/tmp/kotlin-classes/debugUnitTest:/home/grzeg/Android/AndroidStudioProjects/BugReport/app/build/tmp/kotlin-classes/debug:/home/grzeg/Android/AndroidStudioProjects/BugReport/app/build/generated/res/resValues/debug:/home/grzeg/.gradle/caches/modules-2/files-2.1/junit/junit/4.13.2/8ac9e16d933b6fb43bc7f576336b8f4d7eb5ba12/junit-4.13.2.jar:/home/grzeg/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar:/home/grzeg/.gradle/caches/modules-2/files-2.1/org.junit.platform/junit-platform-commons/1.7.1/7c49f0074842d07f4335de2389d624a7437d1407/junit-platform-commons-1.7.1.jar:/home/grzeg/.gradle/caches/modules-2/files-2.1/org.junit.jupiter/junit-jupiter-params/5.7.1/6f81b3c053433a8a40a378d2b4f056c5c31e50ff/junit-jupiter-params-5.7.1.jar:/home/grzeg/.gradle/caches/modules-2/files-2.1/org.junit.jupiter/junit-jupiter-api/5.7.1/a7261dff44e64aea7f621842eac5977fd6d2412d/junit-jupiter-api-5.7.1.jar:/home/grzeg/.gradle/caches/modules-2/files-2.1/org.apiguardian/apiguardian-api/1.1.0/fc9dff4bb36d627bdc553de77e1f17efd790876c/apiguardian-api-1.1.0.jar:/home/grzeg/.gradle/caches/modules-2/files-2.1/org.opentest4j/opentest4j/1.2.0/28c11eb91f9b6d8e200631d46e20a7f407f2a046/opentest4j-1.2.0.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/ad78c6a7380ca3f9c7a1398b89fa62f3/junit-1.1.3/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/8fffe810368f55a6a59ebbaf0e9f7aa6/espresso-core-3.4.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/eb299cf707bde01622cf916a326fd5f8/runner-1.4.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/bf0b12b25a9ce9740353666617faf3f8/core-1.4.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/c3fc6e9b1d764a98eebcf0a45115f338/storage-1.4.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/67c0f4e7eff023867cb4cd50493758f3/monitor-1.4.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/f6269bf09fa88fdbdd5c2efc078c3bfe/core-runtime-2.0.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/098e3cbb790819957cff896f250a4717/espresso-idling-resource-3.4.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.5.21/2f537cad7e9eeb9da73738c8812e1e4cf9b62e4e/kotlin-stdlib-1.5.21.jar:/home/grzeg/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar:/home/grzeg/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.5.21/cc8bf3586fd2ebcf234058b9440bb406e62dfacb/kotlin-stdlib-common-1.5.21.jar:/home/grzeg/.gradle/caches/modules-2/files-2.1/androidx.collection/collection/1.1.0/1f27220b47669781457de0d600849a5de0e89909/collection-1.1.0.jar:/home/grzeg/.gradle/caches/modules-2/files-2.1/androidx.lifecycle/lifecycle-common/2.3.1/fc466261d52f4433863642fb40d12441ae274a98/lifecycle-common-2.3.1.jar:/home/grzeg/.gradle/caches/modules-2/files-2.1/androidx.arch.core/core-common/2.1.0/b3152fc64428c9354344bd89848ecddc09b6f07e/core-common-2.1.0.jar:/home/grzeg/.gradle/caches/modules-2/files-2.1/androidx.annotation/annotation/1.2.0/57136ff68ee784c6e19db34ed4a175338fadfde1/annotation-1.2.0.jar:/home/grzeg/.gradle/caches/modules-2/files-2.1/androidx.constraintlayout/constraintlayout-solver/2.0.1/30988fe2d77f3fe3bf7551bb8a8b795fad7e7226/constraintlayout-solver-2.0.1.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/a8e78915166aa0074d6b796b6207670d/core-ktx-1.6.0/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/a8e78915166aa0074d6b796b6207670d/core-ktx-1.6.0/res:/home/grzeg/.gradle/caches/transforms-2/files-2.1/a8e78915166aa0074d6b796b6207670d/core-ktx-1.6.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/c78e2c0af5afa33232d9367e0579742a/material-1.4.0/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/c78e2c0af5afa33232d9367e0579742a/material-1.4.0/res:/home/grzeg/.gradle/caches/transforms-2/files-2.1/c78e2c0af5afa33232d9367e0579742a/material-1.4.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/a9311d74d80edcfc384ea90c9cbb4fb3/constraintlayout-2.0.1/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/a9311d74d80edcfc384ea90c9cbb4fb3/constraintlayout-2.0.1/res:/home/grzeg/.gradle/caches/transforms-2/files-2.1/a9311d74d80edcfc384ea90c9cbb4fb3/constraintlayout-2.0.1/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/6d782081d97e8f420d203a315c65d750/appcompat-1.3.1/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/6d782081d97e8f420d203a315c65d750/appcompat-1.3.1/res:/home/grzeg/.gradle/caches/transforms-2/files-2.1/6d782081d97e8f420d203a315c65d750/appcompat-1.3.1/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/dafeb60989f149d261f75912da5819c3/viewpager2-1.0.0/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/dafeb60989f149d261f75912da5819c3/viewpager2-1.0.0/res:/home/grzeg/.gradle/caches/transforms-2/files-2.1/dafeb60989f149d261f75912da5819c3/viewpager2-1.0.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/ff953813e061668d7ca6bd69b08e4cf3/fragment-1.3.6/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/ff953813e061668d7ca6bd69b08e4cf3/fragment-1.3.6/res:/home/grzeg/.gradle/caches/transforms-2/files-2.1/ff953813e061668d7ca6bd69b08e4cf3/fragment-1.3.6/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/43ca32ca07dcfaf0937dbabca8cde04b/activity-1.2.4/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/43ca32ca07dcfaf0937dbabca8cde04b/activity-1.2.4/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/85bdfd2364ffc1836850c08a38d50e68/appcompat-resources-1.3.1/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/85bdfd2364ffc1836850c08a38d50e68/appcompat-resources-1.3.1/res:/home/grzeg/.gradle/caches/transforms-2/files-2.1/85bdfd2364ffc1836850c08a38d50e68/appcompat-resources-1.3.1/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/715842898e8d0f21c004cfc21e10f9e2/drawerlayout-1.0.0/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/715842898e8d0f21c004cfc21e10f9e2/drawerlayout-1.0.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/8e6a20d7fc9c099ccd7eba17798bb58f/coordinatorlayout-1.1.0/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/8e6a20d7fc9c099ccd7eba17798bb58f/coordinatorlayout-1.1.0/res:/home/grzeg/.gradle/caches/transforms-2/files-2.1/8e6a20d7fc9c099ccd7eba17798bb58f/coordinatorlayout-1.1.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/6d46647d828d9f08f8e88e5942790788/dynamicanimation-1.0.0/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/6d46647d828d9f08f8e88e5942790788/dynamicanimation-1.0.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/f953ab4f37885764354d84ddfde52cef/recyclerview-1.1.0/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/f953ab4f37885764354d84ddfde52cef/recyclerview-1.1.0/res:/home/grzeg/.gradle/caches/transforms-2/files-2.1/f953ab4f37885764354d84ddfde52cef/recyclerview-1.1.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/1d8550c1f5de451c55fc6403408c54e6/transition-1.2.0/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/1d8550c1f5de451c55fc6403408c54e6/transition-1.2.0/res:/home/grzeg/.gradle/caches/transforms-2/files-2.1/1d8550c1f5de451c55fc6403408c54e6/transition-1.2.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/31a64ca6ed8676f803ec755f43a77806/vectordrawable-animated-1.1.0/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/31a64ca6ed8676f803ec755f43a77806/vectordrawable-animated-1.1.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/f04385de59c26420d58d147a9a74fe51/vectordrawable-1.1.0/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/f04385de59c26420d58d147a9a74fe51/vectordrawable-1.1.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/35b89a7df077b7fd54f833295eaf549b/viewpager-1.0.0/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/35b89a7df077b7fd54f833295eaf549b/viewpager-1.0.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/f2e5b1206570a82806e1a197ad24a53b/legacy-support-core-utils-1.0.0/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/f2e5b1206570a82806e1a197ad24a53b/legacy-support-core-utils-1.0.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/bcf16181c4de1d212fa3db965560e89d/loader-1.0.0/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/bcf16181c4de1d212fa3db965560e89d/loader-1.0.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/5db7002fd679cf8fc5b68e26cfdd44d3/customview-1.0.0/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/5db7002fd679cf8fc5b68e26cfdd44d3/customview-1.0.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/ba1d9cdeace3374a3d1f11cb4c3f7039/core-1.6.0/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/ba1d9cdeace3374a3d1f11cb4c3f7039/core-1.6.0/res:/home/grzeg/.gradle/caches/transforms-2/files-2.1/ba1d9cdeace3374a3d1f11cb4c3f7039/core-1.6.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/6beb34cd66cfb7058da4244864872e09/cursoradapter-1.0.0/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/6beb34cd66cfb7058da4244864872e09/cursoradapter-1.0.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/112d19ed6f1e45d7592b5c2efe66c21b/lifecycle-viewmodel-savedstate-2.3.1/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/112d19ed6f1e45d7592b5c2efe66c21b/lifecycle-viewmodel-savedstate-2.3.1/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/667b1ae5e8f10d0da20d4ac6a4548ab6/savedstate-1.1.0/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/667b1ae5e8f10d0da20d4ac6a4548ab6/savedstate-1.1.0/res:/home/grzeg/.gradle/caches/transforms-2/files-2.1/667b1ae5e8f10d0da20d4ac6a4548ab6/savedstate-1.1.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/b46b3f9f320747dbae98e35027f70956/cardview-1.0.0/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/b46b3f9f320747dbae98e35027f70956/cardview-1.0.0/res:/home/grzeg/.gradle/caches/transforms-2/files-2.1/b46b3f9f320747dbae98e35027f70956/cardview-1.0.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/b8b2e3b141c865387d31f833098d4c29/lifecycle-runtime-2.3.1/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/b8b2e3b141c865387d31f833098d4c29/lifecycle-runtime-2.3.1/res:/home/grzeg/.gradle/caches/transforms-2/files-2.1/b8b2e3b141c865387d31f833098d4c29/lifecycle-runtime-2.3.1/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/6a605a23ec971aaf0adfa6c7baa84e76/versionedparcelable-1.1.1/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/6a605a23ec971aaf0adfa6c7baa84e76/versionedparcelable-1.1.1/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/6d0e5509430d526216677a7e0712ffcd/lifecycle-viewmodel-2.3.1/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/6d0e5509430d526216677a7e0712ffcd/lifecycle-viewmodel-2.3.1/res:/home/grzeg/.gradle/caches/transforms-2/files-2.1/6d0e5509430d526216677a7e0712ffcd/lifecycle-viewmodel-2.3.1/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/7565da836257268c70c5556d1df8a86b/lifecycle-livedata-2.0.0/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/7565da836257268c70c5556d1df8a86b/lifecycle-livedata-2.0.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/d1d24109638c6dd67c123b6cd4bcd859/lifecycle-livedata-core-2.3.1/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/d1d24109638c6dd67c123b6cd4bcd859/lifecycle-livedata-core-2.3.1/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/c05c2560aa638e51e1584e20fc898d4a/core-runtime-2.1.0/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/c05c2560aa638e51e1584e20fc898d4a/core-runtime-2.1.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/467156583574eb755c4e2afa393e7e04/interpolator-1.0.0/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/467156583574eb755c4e2afa393e7e04/interpolator-1.0.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/43a76a240df6409a668896b320cdb11f/documentfile-1.0.0/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/43a76a240df6409a668896b320cdb11f/documentfile-1.0.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/006f75501ee49bd5eb21e79e4363589a/localbroadcastmanager-1.0.0/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/006f75501ee49bd5eb21e79e4363589a/localbroadcastmanager-1.0.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/76cf6e48a6f215ca02fb8be5d7ec1d75/print-1.0.0/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/76cf6e48a6f215ca02fb8be5d7ec1d75/print-1.0.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/transforms-2/files-2.1/2309c301d9c715399ce59dfc6758a6c1/annotation-experimental-1.1.0/jars/classes.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/2309c301d9c715399ce59dfc6758a6c1/annotation-experimental-1.1.0/res:/home/grzeg/.gradle/caches/transforms-2/files-2.1/2309c301d9c715399ce59dfc6758a6c1/annotation-experimental-1.1.0/AndroidManifest.xml:/home/grzeg/.gradle/caches/modules-2/files-2.1/org.junit.jupiter/junit-jupiter-engine/5.7.1/7fcfa59c5533abb41f86b1408960737eeaf1f49f/junit-jupiter-engine-5.7.1.jar:/home/grzeg/.gradle/caches/modules-2/files-2.1/org.junit.platform/junit-platform-engine/1.7.1/d276a968c57f5d60a421dedd1f8b6ca2fae09e86/junit-platform-engine-1.7.1.jar:/home/grzeg/.gradle/caches/modules-2/files-2.1/org.junit.vintage/junit-vintage-engine/5.7.1/8184800e1a38965b3fb62a104458678835311e94/junit-vintage-engine-5.7.1.jar:/home/grzeg/.gradle/caches/transforms-2/files-2.1/92ab5f6ce5f14aa9ae87bcae36c1ca6d/tracing-1.0.0/jars/classes.jar:/home/grzeg/Android/AndroidStudioProjects/BugReport/app/build/intermediates/java_res/debugUnitTest/out:/home/grzeg/Android/AndroidStudioProjects/BugReport/app/build/intermediates/java_res/debug/out:/home/grzeg/.gradle/caches/transforms-2/files-2.1/46679f6f14f1cc8428e02f4c9fc1a544/android.jar com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit5 #w#/tmp/idea_working_dirs_junit.tmp #/tmp/idea_junit.tmp -socket35491
Any idea how to configure gradle "test" task to run JUnit5?
Do you have
test {
useJUnitPlatform()
}
in your build.gradle file?
I have been trying to set up server-side testing for my application but have run into an issue with bamboo recognizing more than one test type. In the past, it worked just fine using only karma as the unit test, but I need to add server-side testing which works much better with jest.
The main problem I am running into is that when both are run as shown below the coverage report is only created for the karma(unit) tests.
test-unit=npm run test:unit && npm run test:server
I have also tried running jest under bamboos test-e2e and test-contract-test but when I do this nothing is reported. So is there a way to set up server-side testing separately in the .bamboorc file
So, I found an answer!
In the .bamboorc file move the test-unit = npm run test:unit to the end of the file and for the first test use
test-contract-consumer=npm run test:server -- --collect-coverage
This should then collect the coverage for the server tests in bamboo under the contract tests consumer artifacts, and the karma unit test should still show up under the unit test coverage artifacts.
I am using the test-library for React , and everytime I edit my test file and save it, it will automatically running coverage on other untested files and gave me a report. there are hundreds of files in my project,and it could really waste time. I don't want this, I just want it run test on my current selected file.
the command I have used is
npm run test /myprojrct/myFile.test.js
is there a way to resolve it ?
Adding the --watch flag to your test script should make jest run tests only on changed files after each save.
More details and other available options can be found here: https://jestjs.io/docs/en/cli#--watch
You should add --coverage=false flag to prevent collecting coverage.
npm run test --coverage=false
Other useful flags:
npm run test --watch // watcher will re-run only the tests that depend on the changed files
npm run test --watchAll // watcher will re-run *ALL* tests when a file has changed
npm run test -t="rendering Button" // will run only tests with a name that matches the regex
npm run test fileName.js // this argument will be treated as a regular expression to match against files in your project
Has anyone attempted to integrate jest unit tests with TFS 2015? I tried to use Chutzpah Test Adapter (https://visualstudiogallery.msdn.microsoft.com/f8741f04-bae4-4900-81c7-7c9bfb9ed1fe?SRC=VSIDE) however it's not able to recognize jest. I receive below error:
Can't find variable Jest
When I run the unit tests through "npm test" I get the results. However to integrate with TFS 2015 I need a test runner which can run Jest unit test so that I can run the unit tests in conjunction with vstest.console.exe which the TFS 2015 provides so it can manage build results and publish results in the build summary report.
Any help would be appreciated!!
Any test runner which can run tests using below command should work (considering VS 2015 installed on the system):
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" "\test.js" /UseVsixExtensions:true
Extending on Merlin's answer, here is how I've implemented publishing jest test results AND code coverage to TFS2015 vNext builds (I am using create-react-app boilerplate):
First install required packages on the Server you are running your Agent on:
npm install -g jest-json-to-tap
npm install -g tap-xunit
configure jest to output json, by changing in package.json the "test" task to:
"test": "react-scripts test --env=jsdom --json",
configure jest options in package.json:
"jest": { "coverageReporters": ["cobertura"] }
created a vNext build (TFS2015v4) with the following tasks:
a. "npm" task, command=run, arguments=test -- --coverage | jest-json-to-tap | tap-xunit > TEST-result.xml
b. "publish test results" task, format=JUnit
c. "public code coverage results" task, code coverage tool=Cobertura, Summary file=$(Build.Repository.LocalPath)\coverage\cobertura-coverage.xml
make sure your build's "Variables" include setting the environment variable "CI"="true"
NOTES:
- test results will not include times nor assemblies - something to extend for the future...
Voila'! Running this build will correctly publish the test results and code coverage stats, as well as report artifacts.
I'm not sure about jest, but there's a neat npm package that can convert TAP based results to xUnit XMLformat, and then you can publish that to TFS.
Take a look at tap-xunit.
I had a build environment where javascript testing was done by various tools and frameworks (AVA, Mocha, Jasmine etc). We decided to export them all to TAP format, run them throw tap-xunit and then publish to TFS.
Basically, you need something like this:
npm test | tap-xunit > results.xml
You pipe the results to tap-xunit and save them to an XML. This gives you an XML formatted as xUnit that you can publish to TFS. If you're running TFS 2015, I strongly recommend going with vNext builds, a lot easier to get these running. Check the "Publish Test Results" build step.
If you are running with XAML build, this link will help you: Javascript Unit Tests on Team Foundation Service with Chutzpah
If you are running with vNext build, please try the detail steps mentioned with Jasmine.JS test(also a kind of JavaScript test ) in this blog.