Quantcast

Using Fakes causes components that should not be listed

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Using Fakes causes components that should not be listed

jabbera

Hello,

 

I’m using sonarqube 5.1 and current c# plugin with TFS 2013 msbuild integration.

 

We have test projects that use fakes to shim\mock some classes\interfaces. As part of this process the build generates actual csproj files and compiles code. These generated projects get listed as components as you can see in the screenshot below.

 

http://imgur.com/v6hzRiE

 

As a textual description going to the components list for this project lists the following:

 

<SNIP>.IO

<SNIP>.IO.Test

f

f

 

The generated projects should be excluded from listings in sonar all together.

 

Thanks!

Mike

 

 

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using Fakes causes components that should not be listed

duncanpMS
This post has NOT been accepted by the mailing list yet.
Thanks Mike.

I've raised issue SONARMSBRU-26 to track this.

As a quick and dirty workaround, you could try creating a separate targets file with the following content and drop it in the [PROGRAMFILES86]\MSBuild\12.0\Microsoft.CommonTargets.ImportBefore folder:

<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
  <PropertyGroup>
    <SonarQubeExclude Condition='$(AssemblyName.EndsWith(".fakes", System.StringComparison.OrdinalIgnoreCase))'>true</SonarQubeExclude>
  </PropertyGroup>
</Project>

Regards,
Duncan
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using Fakes causes components that should not be listed

Dinesh Bolkensteyn-2
In reply to this post by jabbera
<<Posting on behalf of Duncan>>

Sure.

 

FYI “Fakes” are an MS technology that allow you to intercept calls to binaries during tests.

 

For example, if you were testing a component that called System.DateTime.Now, the test would normally have no way of knowing what time would be returned. You could use Fakes to intercept the call to System.DateTime.Now to return a known value.

The general guidance is to avoid using Fakes if you can i.e. design your code to be testable. However, that isn’t always possible e.g. with legacy code.

 

Regards,

Duncan



On Tue, May 19, 2015 at 4:21 PM, Michael Barry <[hidden email]> wrote:

Hello,

 

I’m using sonarqube 5.1 and current c# plugin with TFS 2013 msbuild integration.

 

We have test projects that use fakes to shim\mock some classes\interfaces. As part of this process the build generates actual csproj files and compiles code. These generated projects get listed as components as you can see in the screenshot below.

 

http://imgur.com/v6hzRiE

 

As a textual description going to the components list for this project lists the following:

 

<SNIP>.IO

<SNIP>.IO.Test

f

f

 

The generated projects should be excluded from listings in sonar all together.

 

Thanks!

Mike

 

 


Loading...