Why isn't Xcode showing test coverage? - swift

Using Xcode 8.2.1
A suite of Swift XCT unit tests isn't highlighting code coverage (with green/red highlighting and numbering) on the corresponding swift file when run.
I have ticked code coverage : Gather coverage data in the test
scheme.
I have tried deleting ~/Library/Developer/Xcode/DerivedData and
~/Library/com.apple.dt.Xcode, in finder.
I have tried quitting simulator and running again.
I have tried running all tests with cmd ⌘ +
U, the diamond in the test class, and individual tests.
All tests are passing
I know the report navigator can show coverage but it is in a detached way.

Works fine on my machine:
Don't forget to choose Editor > Show Code Coverage (you didn't mention that in your little checklist).

Related

how to show vue testing-library tests in vs code?

I've installed #testing-library/vue for a Vue project. I use VS Code as my IDE. Seems like I remember test runner integration in VS Code which will auto-display an aggregated list of all tests which exist in the app (files ending in test.js) but I don't see a way to display that test runner view in my default VS Code installation/configuration.
Looks like there's a "Test Explorer UI" Extension that I can install in VS Code which has 1.9M downloads so I'm guessing that's the most popular test runner for VS Code integration. I installed that extension and selected View > Testing from the toolbar. That displayed a "TESTING" panel on the left side of the IDE although no tests are displayed in that panel.
So is there anything special that I need to do in order for tests to display in this panel? Not sure if I need to install another dependency, configure an additional file, run some type of npm script, etc.

Netbeans CUnit runs once per application launch

I am using Netbeans 8.1 with CUnit testing. I can run and test my project just fine, and it spits out the correct results. However, when I try to test it again it does not give me results. Instead it only says:
CUnit - A unit testing framework for C - Version 2.1-3
http://cunit.sourceforge.net/
This persists even if I change the actual code of the project. It will only give me the results when I restart the program. I would like to know how to get the updated test results without having to restart the program.
I found a workaround: add a dummy C Simple Test test that always passes.
Turned out if I have C Unit and C Simple Test tests in the same project and when I run Test Project from the menu both works properly.

NUnit 3.2: Autorun tests after compile (Windows)

On a new VS solution, I've started using NUnit 3.2. Older versions (2.6) had a external NUnit GUI, that made it possible to watch assemblies and automatically run tests on modifications. But I cannot find anything similar to this for 3.2 - neither in the docs nor through Google.
I've installed NUnit.3.2.0.msi, I've also installed the NUnit3 Test Adapter in VS + NUnit3.2 nuget package for my project.
I can easily run all my tests through VS' Test Explorer. But I miss some way to run them automatically. Anyone know how?
In older versions of Visual Studio, there used to be an option to run tests after every build, but it was removed. It was always buggy and tended to lock files and prevent you from rebuilding.
You could set a post build command on your test project to automatically run NUnit console whenever your test project recompiles. You have NUnit console installed, so you could point to that, or use the NUnit.Runners package to install it into the packages folder of your solution.
Open your test project settings and go to the Build Events tab. Click on Edit Post-Build. Enter the following;
"C:\Program Files (x86)\NUnit.org\nunit-console\nunit3-console.exe" "$(TargetPath)"
Now, whenever you build, your tests will be run and the results will appear in the output window.
Maybe not ideal if there is a lot of build output after your tests but it works.
FYI, the colour in the build output is a side-effect of the VSColorOutput Visual Studio extension, it is not from NUnit.
Visual Studio captures STDOUT, so I haven't been able to get it to open a CMD window and run the tests. If anyone knows how to do that, add a comment and I will update.
There is a GUI for NUnit 3 under developement on GitHub - but it's not advised for production use yet.
We set our tests up using the NUnitLite runner. This allows you to turn your test assembly into an executable - and on run, will launch the console and run all tests. [Documentation]

Code Coverage GCov not working with XCode 4.2 and iOS SDK 5

I've been trying to get GCov working with Xcode 4.2Build 4D199 on Lion with iOS SDK 5.0 to no avail. Has anyone had any luck with this? I'm using Google Tools For Mac for my unit tests and I've linked in libprofile_rt.dylib and added:
"OTHER_CFLAGS[arch=*]" = (
"-ftest-coverage",
"-fprofile-arcs",
"-falign-loops=16",
);
as indicated on the Coverstory page here http://code.google.com/p/coverstory/wiki/UsingCoverstory
But when I find . -name *.gcda" I come up empty. What am I missing?
GCov is no longer supported in XCode 4.2. You'll note that if you go their "man page" for it, XCode 4.2 is not an option in the drop down list. Furthermore, if you look at the compile, it's using "c++", which is linked to llvm-g++-4.2. They now exclusively use the Clang/LLVM tool chain (which in turn often makes use of the gcc tool chain) instead of giving you the option of directly using the gcc tool chain. A consequence of this is that doing code coverage in XCode4 with gcov is no longer directly available. This also can affect compiles using CMake that bypass XCode 4. That first link gives you instructions on how to change your project to use profile_rt instead of gcov.
How to generate coverage test reports (Xcode 4.5 edition)
cd to your Xcode project and type
git clone git#github.com:j4n0/XcodeCoverage.git
cd XcodeCoverage
wget http://downloads.sourceforge.net/ltp/lcov-1.10.tar.gz
tar -zxvf lcov-1.10.tar.gz
Set the following build properties on both your main target and your SentestKit target, but only for the Debug configuration (expand the node, there are Debug and Release entries):
Generate Profiling code Yes
Generate Test Coverage Files Yes
Instrument Program Flow Yes
Install Xcode command line tools: Xcode > Preferences > Downloads > Command Line Tools.
In your main target, add a “Run Script” build phase to execute ./XcodeCoverage/exportenv.sh
Build your application, and run the tests.
Generate the coverage report from the XcodeCoverage typing: ./getcov
Upon completion, the script will launch a browser with the html output.
If reports are not generated try this:
Edit the plist of your application and add the following:
<key>UIApplicationExitsOnSuspend</key>
<true/>
Then run your application and press Home. This will quit cleanly and generate the gcda files.
If it still doesn't work, try using the iPad simulator instead.
For more tips and tricks check the talk Code Coverage on iOS by Richard Buckle.

How to Integrate NUnit With VS 2008

Hi i created a unit test case using NUnit.When i run the test NUnit it works fine.But i need to run it by using Visual studio.So i referred the NUnit website and followed the below steps
1)Right clicked the test project and clicked properties |Chose Debug option
2)checked the external program option and choosed the nUnit exe file.
3)And i run the test
Error i got:
Cannot start because the test project does not contain any test method.But i included 4 test methods which works in NUnit GUI.
Thanks in advance
Check out TestDriven.NET, a free Visual Studio add-in that allows you to run your unit tests with NUnit directly from the IDE.
Also ReSharper beautifully supports testing with NUnit!
http://www.jetbrains.com/resharper/features/unit_testing.html
On the Debug options tab, make sure to also set a command line argument with the name of your test assembly.