Go test coverage for test files in separate module [duplicate] - go

This question already has answers here:
No test coverage when tests are in a different package
(2 answers)
Go Test Coverage, over different packages [duplicate]
(1 answer)
Go Coverage not including functions in other package
(2 answers)
Closed 26 days ago.
I'm running gotestsum --junitfile-testcase-classname=short --junitfile-testsuite-name=relative \ -- -coverprofile=coverage.out ./serviceName/...
The structure looks like this:
serviceName
normalModule
- file.go
- file_test.go
testModule
- file2_test.go
- file3_test.go
otherModule
- file3.go
- file2.go
How can I generate a test report that will account for all corresponding test files outside of its own module?
Note: I am trying to avoid reorg
Tried above command and expected normalModule, otherModule, and serviceName module to report coverage.
Currently the coverage report only shows a coverage for normalModule and skips the rest:
serviceName/normalModule (5ms) (coverage: 100.0% of statements)
∅ serviceName
∅ serviceName/testModule
∅ serviceName/testModule

Related

Golang Bazel empty coverage_report.dat

I am working on a small Golang monorepo and I am using Bazel + gazelle to manage deps along with tests, builds, coverage,...
I am having an issue when it comes to coverage. I have followed a few examples but for some reason the coverage_report.dat file (that then will be processed by genhtml) is always empty.
This is the command that I am running with relative output
$ bazel coverage --combined_report=lcov --cache_test_results=no --test_output=all //...
INFO: Using default value for --instrumentation_filter: "^//service/hello[/:],^//service/hellotwo[/:]".
INFO: Override the above default with --instrumentation_filter
INFO: Analyzed 4 targets (0 packages loaded, 0 targets configured).
INFO: Found 2 targets and 2 test targets...
INFO: From Testing //service/hello:hello_test:
==================== Test output for //service/hello:hello_test:
PASS
coverage: 100.0% of statements
================================================================================
INFO: From Testing //service/hellotwo:hellotwo_test:
==================== Test output for //service/hellotwo:hellotwo_test:
PASS
coverage: 100.0% of statements
================================================================================
INFO: LCOV coverage report is located at /private/var/tmp/_bazel_andrea/292e77b095155ea362773b482c2c4621/execroot/__main__/bazel-out/_coverage/_coverage_report.dat
and execpath is bazel-out/_coverage/_coverage_report.dat
INFO: Elapsed time: 0.217s, Critical Path: 0.09s
INFO: 3 processes: 1 internal, 2 darwin-sandbox.
INFO: Build completed successfully, 3 total actions
//service/hello:hello_test PASSED in 0.1s
/private/var/tmp/_bazel_andrea/292e77b095155ea362773b482c2c4621/execroot/__main__/bazel-out/darwin-fastbuild/testlogs/service/hello/hello_test/coverage.dat
//service/hellotwo:hellotwo_test PASSED in 0.1s
/private/var/tmp/_bazel_andrea/292e77b095155ea362773b482c2c4621/execroot/__main__/bazel-out/darwin-fastbuild/testlogs/service/hellotwo/hellotwo_test/coverage.dat
Executed 2 out of 2 tests: 2 tests pass.
INFO: Build completed successfully, 3 total actions
The coverage is calculated but bazel-out/_coverage/_coverage_report.dat is empty. I was wondering if anyone has had this issue before and managed to find a solution to it.
I am working on a MacBook Pro with Bazel (v4.1.0) installed via Homebrew.

In Cucumber : How to show the Total scenario executed count properly in the console output

I am running Cucumber Junit test in JAVA using Spring Boot Project and I am getting my console output as below
Tests passed :30 of 30 tests
Note : Actually I am running only 10 scenarios with each scenario 2 steps but the output shows as (10 + 10*2 = 30 passed) . This number is not making scenes . It should show me 10 of 10 tests
In build.gradle file ,
My cucumber version used = '1.2.5'
List cucumber = ["info.cukes:cucumber-jvm:${cucumberVersion}",
"info.cukes:cucumber-core:${cucumberVersion}",
"info.cukes:cucumber-java:${cucumberVersion}",
"info.cukes:cucumber-junit:${cucumberVersion}",
"info.cukes:cucumber-spring:${cucumberVersion}"]
Is there any way i can give a meaningful output instead of adding the steps count again with the actual scenarios count ?

jmeter(5.0) load testing and reports generation [duplicate]

This question already has answers here:
How do I generate a Dashboard Report in jmeter?
(6 answers)
Closed 4 years ago.
I have done load testing with jmeter and my jmeter version is 5.0.
Can you please help me how to generate the reports of the results.
Given you executed JMeter in command-line non-GUI mode like:
jmeter -n -t /path/to/test.jmx -l /path/to/result.csv
You can now generate the HTML Reporting Dashboard from the result.csv file as follows:
jmeter -g /path/to/result.csv -o /path/to/dashboard/folder
The folder where you will be generating the report to must be empty.
See this new blog (16th january 2019) which explains the while process:
Reporting feature in JMeter
Besides, refer to the reference documentation :
http://jmeter.apache.org/usermanual/generating-dashboard.html

Using Profiler on mono to gather code coverage information does not include the assemblies of the tested dll

Currently I am working on a Xamarin Project using Xamarin Studio on Mac. I have created a NUnit test project to test the core PCL 4.5 library. On command line:
mono --debug --profile=log:report,coverage nunit3-console.exe bin/Debug/MyProject.Core.Tests.dll
and the coverage summary I take on output:
Coverage Summary: nunit.engine
(/Users/Stam/Desktop/NUnit/nunit.engine.dll) 39% covered (656 methods
- 258 covered) NUnit.Engine.Services.ResultService 100% covered (4 methods - 4 covered) NUnit.Engine.Extensibility.ExtensionPoint 25%
covered (12 methods - 3 covered)
NUnit.Engine.Services.TestFilterService 50% covered (2 methods - 1
covered) NUnit.Engine.Agents.TestAgent 50% covered (10 methods - 5
covered) NUnit.Engine.Internal.DirectoryFinder 75% covered (4
methods - 3 covered) NUnit.Engine.Services.TestAgency 88% covered
(17 methods - 15 covered) NUnit.Engine.Internal.SettingsStore 75%
covered (4 methods - 3 covered)
..... more nunit assemblies here
There are not included assemblies here that included to the dll.
Is there any way to do this?
If not is there any other non commercial test code coverage tool I could use on Mac?
You need to run nunit3-console with your test assembly inprocess via:
--process=PROCESS
or
--inprocess
Example
Note: This is removing all the NUnit assemblies and the test assembly that contains the [Test]s, so the output only includes the user code
mono \
--debug \
--profile=log:coverage,onlycoverage,\
covfilter=-nunit3-console,\
covfilter=-nunit.framework,\
covfilter=-Mono.Cecil,\
covfilter=-NUnit.Engine,\
covfilter=-NUnit.Core,\
covfilter=-nunit.core,\
covfilter=-nunit.engine,\
covfilter=-nunit.v2.driver,\
covfilter=-TestAssembly \
packages/NUnit.ConsoleRunner.3.5.0/tools/nunit3-console.exe \
--noh \
--inprocess \
CodeCoverage/bin/Debug/TestAssembly.dll
Output:
>>mprof-report --reports=coverage output.mlpd
Coverage Summary:
MyAssembly (/Users/sushi/Projects/CodeCoverage/CodeCoverage/bin/Debug/MyAssembly.dll) 50% covered (2 methods - 1 covered)
MyAssembly.MyClass 50% covered (2 methods - 1 covered)

How do I run xctest from the command-line with Xcode 5?

I found a command-line tool called "xctest" that apparently can run the unit tests in your project. This executable lives here:
/Applications/Xcode.app/Contents/Developer/usr/bin/xctest
When I try to run this executable on my xctest bundle, I'm using:
$ ./xctest /Users/myusername/Library/Developer/Xcode/DerivedData/MyApp-abcdefghijklmnop/Build/Products/Debug/MyAppTests.xctest
However, I get the following output:
Test Suite '(null)' started at 2013-11-14 21:16:45 +0000
Test Suite '(null)' finished at 2013-11-14 21:16:45 +0000.
Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.001) seconds
There's no man page for xctest, as far as I can tell, but entering just ./xctest at the command-line yields:
Usage: xctest [--test Self | All | None | <TestCaseClassName/testMethodName>] <path of unit to be tested>
In particular, I'd like to be able to test just a particular method in a test class, which is why I'd like to use this xctest command.
I do see that there is a way to run all the tests from the command line like:
$ xcodebuild test -scheme MyApp
This runs all the unit tests and works properly (I see my unit test results, unlike when using xctest). But I'm interested in being able to run a single test method from the command-line, such as:
$ ./xctest --test MyAppTests/testExample /Users/myusername/Library/Developer/Xcode/DerivedData/MyApp-abcdefghijklmnop/Build/Products/Debug/MyAppTests.xctest
Despite what the usage message says -XCTest is the argument you need:
xctest -XCTest MyAppTests/testExample testbundle.xctest
For a direct invocation of xctest to work you may also need to set DYLD_FRAMEWORK_PATH and DYLD_LIBRARY_PATH to your built products directory. In general you need to use the same arguments and environment as Xcode does, you can see this by putting a breakpoint in one of your tests, running them through Xcode, then printing out the values of arguments and environment for [NSProcessInfo processInfo].
To avoid messing with all that note you can also modify the scheme in Xcode to run only specific tests. Under Product > Scheme > Edit Scheme select the Test action and expand the test bundle. You can use the check boxes to select the tests to run and xcodebuild's test action will then run only these tests.

Resources