Tuesday, July 24, 2018

Configuring Jenkins with MSSQL server.


  • Need to install SQL server.
  • Install Java.
  • SQL server is with SQL authentication method.

Below is the sonar config looks like ,But im getting an error.


sonar.jdbc.url=jdbc:sqlserver://localhost;databaseName=SonarQube;instanceName=SQLEXPRESS
sonar.jdbc.username=sonarqube
sonar.jdbc.password=mypassword

java.lang.IllegalStateException: Can not connect to database. Please check connectivity and settings (see the properties prefixed by 'sonar.jdbc.').


Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'com.microsoft.sqlserver.jdbc.SQLServerDriver' for connect URL 'jdbc:sqlserver:localhostSQLEXPRESS;databaseName=SonarQube;instanceName=SQLEXPRESS;selectMethod=cursor;'

Full post:
http://blog.majcica.com/2016/04/28/sonarqube-on-windows-and-ms-sql/

Wednesday, July 11, 2018

Show MSTest coverage on a .net project - Sonar

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Team Tools\Dynami
c Code Coverage Tools>CodeCoverage.exe 
collect /output:VisualStudio.coverage "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" "C:\Program Files (x86)\Jenkins\workspace\dash_\dash\ReportShare\bin\ReportShare.dll"



  1. You have to find the CodeCoverage.exe installation location.

In my PC its inside "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Team Tools\Dynami
c Code Coverage Tools>"

  2.Execute your MSTest dll file by pointing it to CodeCoverage.exe

     3. Then VisualStudio.coverage file will be generate on your CodeCoverage.exe's file location.



C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Team Tools\Dynami
c Code Coverage Tools>CodeCoverage.exe analyze /output:VisualStudio.coveragexml VisualStudio.coverage

  
  4.By pointing to the same CodeCoverage.exe generate the coveragexml file.

     5. Then VisualStudio.coveragexml file will be generate on your CodeCoverage.exe's file           location.




sonar.cs.vscoveragexml.reportsPaths=C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Team Tools/Dynamic Code Coverage Tools/VisualStudio.coveragexml

   6.Then add sonar.cs.vscoveragexml.reportsPaths parameter to your sonar analysis properties and point the newly generated  VisualStudio.coveragexml  file to that property.




DONE!

Tuesday, April 3, 2018

Easy way to switch between windows on appium or selenium

ReadOnlyCollection<string> windowHandles = driver.WindowHandles;
            driver.SwitchTo().Window(windowHandles[1]);

Thursday, March 22, 2018

Sonar EXECUTION FAILURE- "Start pointer should be before end pointer."

10:58:34.592 INFO: EXECUTION FAILURE
10:58:34.592 INFO: ------------------------------------------------------------------------
10:58:34.592 INFO: Total time: 1:00.563s
10:58:34.650 INFO: Final Memory: 41M/105M
10:58:34.650 INFO: ------------------------------------------------------------------------
10:58:34.651 ERROR: Error during SonarQube Scanner execution
java.lang.IllegalArgumentException: Start pointer [line=10, lineOffset=0] should be before end pointer [line=10, lineOffset=0]
 at org.sonar.api.internal.google.common.base.Preconditions.checkArgument(Preconditions.java:145)
 at org.sonar.api.batch.fs.internal.DefaultInputFile.newRangeValidPointers(DefaultInputFile.java:265)
 at org.sonar.api.batch.fs.internal.DefaultInputFile.newRange(DefaultInputFile.java:203)
 at org.sonarsource.dotnet.shared.plugins.SensorContextUtils.toTextRange(SensorContextUtils.java:41)
 at org.sonarsource.dotnet.shared.plugins.protobuf.IssuesImporter.importMessage(IssuesImporter.java:54)

Above is the sample output of my sonar execution failure output.
Above out put is for a C# project.
I was looking for a fix to resolve this issue.
Some have mention to disable some of the c# rules on the sonar profile.
But it didnt work for me.

So i update the sonar c# plugin from the sonar update center.
But still NO LUCK.

Then I manually download an older version of sonar-csharp-plugin and try to execute the sonar scanner.
But still NO LUCK.

Then i tried with more older versions and finally sonar-csharp-plugin-5.1-RC3.jar and it works well.

URL for older versions of sonar c sharp plugin
https://github.com/SonarSource/sonar-csharp/releases?after=5.2

Wednesday, November 22, 2017

Error while reading an excel file as a sql table-'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine

Im having a xlsx  file which contain some data as on the below image and i need to read them and store as a SQL data table or as an string array.

So any how my ultimate goal is to read the data from a excel file.

But i got this stupid error.

'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine'



string path = @"C:\temp\GOSTestDetails.xlsx";
            string connStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;";

            string[] DashboardName = new string[100];
            int i = 0;
            int j = 0;
using (OleDbConnection connection = new OleDbConnection(connStr))
            {
                connection.Open();
                OleDbCommand command = new OleDbCommand("select * from [TestDetails$]", connection);
using (OleDbDataReader dr = command.ExecuteReader())
                {
                    dr.NextResult();
                    for ( j = 0; j < dr.FieldCount; j++)
                    {
                        
                        var row1Col0 = dr[j];
                           
                            DashboardName[i++] =                    row1Col0.ToString();
                    }

                }
            }
        }

So the solution is to download and install 

Microsoft Access Database Engine 2010 Redistributable.



Tuesday, August 1, 2017

HTTP Error 500.19 and error code : 0x80070021 at IIS 10.


FIX

Go to C:\Windows\System32\inetsrv\config\applicationHost.config and open in notepad.
Search for a text "handlers".
You will find something like below.
<section name="handlers" overrideModeDefault="Deny" /> change this value from "Deny" to "Allow"



Or 

Search for a text "modules".
You will find something like below.
<section name="modules" allowDefinition="MachineToApplication" overrideModeDefault="Deny" /> change this value from "Deny" to "Allow"

Or Both.

Thursday, June 29, 2017

ContextSwitchDeadlock was received ...oops

While im de-buging my CodedUI code on VS 2015 i got this information dialog box.

The CLR has been unable to transition from COM context 0x6d2290 to COM context 0x6d24b8 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, 

This is because of im having some Thread.Sleep()  lines all over the code and some of them contain more than 1 minute.

So the solution to resolve this was to unchecked the ContextSwitchDeadLock check box at

Debug>Exceptions>Manage Debugging Assistants>ContextSwitchDeadLock