-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve code coverage for System.Data.SqlClient (18.1%) #56
Comments
This may help? dotnet/corefx#13665 |
It might help perhaps to port the internal tests for SqlClient to corefx? I assume it has a lot more coverage than the corefx counterpart? |
@saurabh500 coverage for SqlClient is still only 22%. Is there any internal test code that might help, that someone could help clean up possibly? https://ci.dot.net/job/dotnet_corefx/job/master/job/code_coverage_windows/Code_Coverage_Report/ |
These are the types with the most missing blocks, in descending order
@saurabh500 the amount of code is substantial so starting with any existing tests would be ideal. |
Info on code coverage work:
|
@saurabh500 not a high priority, but question above about existing tests for sql client. Is there a body of existing code that we can dump into the repo for folks to begin to clean up and enable as tests? Can you research? @FransBouma another option is borrowing Mono tests. This is totally legitimate. Any interest? |
@danmosemsft there are a lot of tests that we have in our internal repo that I can make available. We also have tests in manual tests folder in sqlclient tests. They are not run automatically due to the absence of a SQL server accessible to these tests in the CI. We run those tests while making changes to sqlclient. They depend on a connection string being provided in environment variable. |
I think a public testserver would indeed be key to get started. Everyone testing against their own local box isn't reliable, I think. |
@danmosemsft There are a lot of tests in System.Data.SqlClient. Where is the lack of code coverage? |
@dhoehna take a look at the all up report linked above https://ci.dot.net/job/dotnet_corefx/job/master/job/code_coverage_windows/Code_Coverage_Report/ search for SqlClient you see there is only 20% coverage. |
@danmosemsft I found that. SO, all the classes under the SqlClient heading need tests? What is Mono? |
@danmosemsft ? |
@dhoehna Mono is an open source project to port .NET to other platforms (originated long ago). We can reuse its tests if they're valuable. Take a look and see: |
@danmosemsft It looks like mono has a tool that generates test databases locally. I'd be glad to try and implement something similar. What do you think? |
I don't own this area. @saurabh500 @corivera can you provide guidance here... |
I want to start working on this, I can start with TdsParser, but I can't find any existing test about it, are they on the repo ? (the coverage report shows 21%) |
The issue with SqlClient is that it needs a server to test most of the code. One of the approaches I had started with, was to use a Test TDS server from which I am returning responses to simple queries. Ref https://github.com/dotnet/corefx/blob/master/src/System.Data.SqlClient/tests/FunctionalTests/DiagnosticTest.cs#L703 |
The example of some of the queries that can be responded to are at One needs to be careful about crafting the response with the right Tds packet. I think more low hanging fruits are public types like |
OK Tds is a bit too difficult for a first time, I'll go to SqlDataRecord and see what I can test. Because it's testing after coding, I plan to comment some instruction, create a failing test, uncomment and check all the tests pass, do you think that's the right approach ? |
I dont quite follow. What do you mean by comment some instructions? |
Comment out some code in SqlDataRecord, write a test that is supposed to validate this part of code, see it fail and then uncomment it and see the test pass (I won't commit the commented code). |
Got it. You could look at the test for SqlDataRecord at https://github.com/dotnet/corefx/blob/master/src/System.Data.SqlClient/tests/FunctionalTests/SqlDataRecordTest.cs It still has low line coverage. You could enhance the test above to pass in a SqlMetadata for the Types the Get methods are currently not testing. After doing this exercise you could move on to the setters. |
@RemiBou If you are comfortable and want to move forward with SqlDataRecord test, I can open a separate issue and we can discuss further on that issue. This is a catch all issue for SqlClient as such and individual Types discussion can be moved to a separate issue to maintain clarity of discussion. |
I you prefer we can do that, or we can discuss on each PR, I'll send a small one (a few test) for validating that I am on the good track |
Here you go https://github.com/dotnet/corefx/issues/27416 |
@saurabh500 , @danmosemsft: is there a mechanism for running code coverage + report generator locally? I'm looking into contributing on this issue and hoping such a mechanism exists. Thanks. |
When you run the tests locally, instead of just doing:
you can do:
See https://github.com/dotnet/corefx/blob/968cfcf373633a82e1dc1850e9852e0c491112dd/Documentation/building/code-coverage.md for more details. |
@stephentoub thanks. If its fine with you, I'm going to start working this issue. This is my first time contributing and I was wondering if it is acceptable to use the AAA pattern when writing unit tests? |
That's fine. Though we don't need each "section" named with a comment as some people do, and it's also fine to collapse them (I personally disagree with folks that it's a test smell doing so). |
Looks like there is still a lot of code coverage to be desired here. I will be digging into Mono tests this week to see if there is anything that can be pulled over. FYI - this link to the mono tests are here now. |
As recently announced in the .NET Blog, focus on new SqlClient features an improvements is moving to the new Microsoft.Data.SqlClient package. For this reason, we are moving this issue to the new repo at https://github.com/dotnet/SqlClient. We will still use https://github.com/dotnet/corefx to track issues on other providers like System.Data.Odbc and System.Data.OleDB, and general ADO.NET and .NET data access issues. |
Hi @danmosemsft The current code coverage for Microsoft.Data.SqlClient is currently ~55% (Internal pipeline report). If you agree, we'd like to close the issue and keep working on code coverage improvement as we move forward. Let us know what you think! |
That's a big improvement, I think it can be closed now 😸 |
Report here
The text was updated successfully, but these errors were encountered: