MUnit test error in Anypoint Studio when project is using Maven - maven

I am trying to introduce MUnit unit tests to an existing Mule project which is using Maven for builds and dependency management.
However I am unable to run the tests visually through Mule Anypoint Studio, when I try to debug them I get the error:
MUnit test could not be run, The Archive
C:/pathtomyuserfolder/.m2/commons-logging/1.2/commons-logging-1.2.jar which is
referenced by the classpath, does not exist.
I can however run the test using Maven using the command "mvn test" but this is not ideal as I want to be able to debug the test, pausing at breakpoints etc.
I can reproduce this problem using the Mule Anypoint Exchange sample here: https://www.mulesoft.com/exchange/#!/munit-example. When I open this project I can debug the tests with no problems, but if I then right click on the project and select Maven Support In Studio -> Mavenize. I am then unable to debug the tests in Studio.
What am I doing wrong? Is this behavior supported?

This turned out to be a problem with the build path on my machine and nothing to do with MUnit.
The clue was in the actual error message above - that the path was missing the /repository folder under my /.m2 folder. I'm not sure how it happened by my M2_REPO was pointing to the wrong level.
The strange thing is that the two projects I tried would still actually run ok, so that's why I thought it was just a problem with MUnit. Sorry for the confusion and thanks to #Ryan and #Dds for your comments. I should have first tried to fix the problems highlighted in Mule Studio before posting.

Related

Generate mule_export.properties with Maven

I'm trying to set up IntelliJ to deploy Mule project that depends on a domain project, but the result builded by Maven does not have META-INF directory and mule_export.properties in it. However, the same build within AnyPoint Studio does produce these artifacts, which make the deployment successful.
Does anyone know how can I force Maven to create these? Either through Maven plugin or IntelliJ associations, as it seems that associations within IDE are the reason this is being produced by AnyPoint Studio.
I'm not sure why do you need the mule_export.properties. It seems to be only generated by Anypoint Studio when exporting a project. However I don't think it is used at all to deploy an application. Probably you are having a different problem. Usually that happens by differences between Maven dependencies and Studio build path.
What is the exact error you are having at deployment?

How to run unit tests in TFS (using vNext)

I have the following project in my Visual Studio 2015 solution. I want to execute jasmine tests as part of our TFS CI build. I can run my tests successfully when I open the SpecRunner.html file although I'm failing to get them to run as part of the TFS build. I've included a screen shot of my TFS build step definition. The build is successful but the tests are not executed.
Please advise, any help greatly appreciated.
Many thanks,
Project and file locations
TFS build step
First make sure your environment on the build sever is set correct. You could manually run the test on the build server.
To use a NuGet package for the Chutzpah test runner , then you can avoid having to manually unpack the VSIX and get it into source control to deploy it to the build host.
About the detail step and build definition you could take a look at this tutorial: nUnit and Jasmine.JS unit tests in TFS/VSO vNext build

Jenkins Throwing error while building .net project

I'm trying to build a .net projects on jenkins. It is throwing error saying nuget packages are missing. I'm unable to get which packages are missing exactly.
when im going inside the visual studio and trying to build the project, it is building properly without any error.
My other .net projects are building absolutely fine on jenkins. Only this project is throwing errors.
applying manual windows batch coomand to restore nuget package required by solution
adding this build step before building the solution so it will restore all the dependencies required by solution.

Sonar server is showing Unit test coverage empty although i am using open cover

I am new to sonar and trying to use Sonar for code analysis including code coverage, unit test report etc. I am able to generate a report using OpenCover, i am using C#. My project is part of a jenkins job which build the soluton, run script for Opencover and then connect to sonar using 'Execute sonarQube scanner'. I am able to view result as line of code smell, issues in sonar. But unit test section is showing 0 in all parts (Failures, errors, tests). Below are my sonar setting in sonar-project.properties.
sonar.projectKey=TestCI
sonar.projectVersion=1.0
sonar.projectName=TestCI
sonar.sources=.
sonar.language=cs
sonar.cs.vstest.reportsPaths="%WORKSPACE%\AutoBuildTest\Results.trx"
sonar.dotnet.visualstudio.solution.file="%Workspace%\TestCI.sln"
sonar.cs.msbuild.testProjectPattern=*Tests;*UnitTests
sonar.cs.opencover.reportPaths="%WORKSPACE%\GeneratedReports\TestCI.xml"
sonar.cs.vscoveragexml.reportsPaths="%WORKSPACE%\GeneratedReports\TestCI.xml"
Please help.
So i was trying to get my head around this, googling around and not finding concrete solution.
I am new to CI, so i do not know many things. I wanted to perform code coverage for my .net application which is running as a jenkins job (build and test steps already configured). I was able to integrate sonarqube as well.
Next step was to cover the code and show output in sonar (all as part of jenkins job). I tried opencover and could see the html output but could not integrate it in sonar. Tried dotCover also but not much use. I was not aware about Galileo so tried that also and it did not work. Then i started coming across post that says Galileo is no longer supported by sonar (version higher than 4.3 and mine was 5.3).
SO i had to start from ground zero again, leaving opencover and dotcover behind. I started looking into visual studio's code coverage tool which was apparently not supported on my version (VS 2015 professional). So i changed it to VS 2015 Enterprise. Now i could access code coverage tool under "%VS_INSTALL_DIR%\Microsoft Visual Studio 14.0\Team Tools\Dynamic Code Coverage Tools". Next step was to integrate all this in jenkins. I had to use "collect" with code coverage tool (giving my tests project dll as input) and then run "analyze" on code coverage tool (which basically converts binary file generated in "collect" to xml file).
Now when i ran this from my machine, from my development project's dll, it all worked fine and i could run sonar-runner (in command line after changing to path of my project) i could see the magical output in sonarqube server (the one that runs on localhost:9000). But when i repeated same in jenkins (using batch command) nothing happened. What went wrong
Make sure sonar-project.properties file is correct.
When i could not find anything in sonar i checked the xml file getting generated by code coverage tool (using analyze step). There reference for dll was from my local project and not the one i am building in jenkins. I opened project downloaded by jenkins from github (as part of build step). The reference was all fine. Test project was pointing to project downloaded from github. SO where was the error?
I forgot to rebuild the solution so that it will clear the old reference and build new one with new location.
It looks long answer but it took me longer to figure out (although i read it during my R&D but could not understand why would i need it)
Thanks Shaun for suggestions. I still could not figure out how opencover is running on nemo.sonarsource.org (version is 5.6) but i will save that for some other day.

Unit Tests are failing on a "Build failed" in the Session window with no message providing a reason for failure in Visual Studios 2010

I had recently installed VS 2010 on my local machine, and cannot seem to get Resharper 5.1 and the unit tests to work correctly.
Whenever I try and run Unit tests I get a "Build failed" with the test icon remaining gray, but with no info in the output window and no discernible reason why.
The Unit Tests run perfectly fine when doing a nant build.
Running a previous branch of the code on VS 2008 does not have this same issue as a result.
Any ideas?
Check your build configuration. If you're using a build configuration that is set to not build your test projects (like your release configuration) then the Resharper test runner will fail this way. The output looks like a perfectly successful build but if you inspect the output you'll find your tests are not in it.
Another symptom of this issue is if you set the test runner to not build as suggested above, next time you attempt to run the test it will be crossed out in the test runner.
Build configurations can be found in Build->Configuration Manager in Visual Studio.
If you change the build settings to 'never build' in the unit test sessions window, it works ok (providing you pre-build the dll using visual studio). It appears to be a Resharper bug.
In my case this did solve the issue:
http://www.shirmanov.com/2011/07/project-has-not-been-built-resharper.html
I had the UnitTests set "to not build" in my solution configuration.
The above mentioned article shows this very detailed.
In my case I was missing a DLL that was not added to the project. I added it, cleaned and build and everything was okay.
Verify in Visual Studio Configuration Manager that your test projects are marked to be build.

Resources