Skip to content
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

TraceFile's coverage is wrong #15

Open
yamadakin opened this issue Feb 26, 2016 · 1 comment
Open

TraceFile's coverage is wrong #15

yamadakin opened this issue Feb 26, 2016 · 1 comment

Comments

@yamadakin
Copy link

■my test procedure
CREATE PROCEDURE [dbo].[OutputDemo]
@name varchar(50),
@Age int,
@resName varchar(50) OUTPUT,
@reSage int OUTPUT
AS
if @Age >=100
begin
SET @reSage= @Age * 2
SET @resName = 'Name: ' + @name
end
else
begin
SET @reSage= @Age + 10
SET @resName = 'Name: ' + @name
end
■my unit test(TestProject1.dll)
public class UnitTest1 {
[TestMethod]
public void TestMethod1() {

        //var db = new PetaPoco.Database("Data Source=.;Initial Catalog=AdventureWorks2008R2;Trusted_connection=True;Application Name=SQLCC", "System.Date.SqlClient");
        var db = new PetaPoco.Database("Data Source=WIN-IVB0M9502MI\\SqlExpress;Initial Catalog=master;Persist Security Info=True;User ID=sa;Password=ko580501@_;Application Name=SQLCC", "System.Date.SqlClient");
        var opName = new SqlParameter("@resName", SqlDbType.VarChar);
        opName.Direction = ParameterDirection.Output;
        opName.Size = 50;
        var opAge = new SqlParameter("@resAge", SqlDbType.Int);
        opAge.Direction = ParameterDirection.Output;
        opAge.Size = 20;
        var s = Sql.Builder.Append(";EXEC OutputDemo @0, @1, @2 OUTPUT, @3 OUTPUT",
           "Markus299",
           299,
           opName,
           opAge
          );
        db.Execute(s);

        System.Console.WriteLine(opName.SqlValue);
        System.Console.WriteLine(opAge.SqlValue);

    }


    [TestMethod]
    public void TestMethod2() {

        //var db = new PetaPoco.Database("Data Source=.;Initial Catalog=AdventureWorks2008R2;Trusted_connection=True;Application Name=SQLCC", "System.Date.SqlClient");
        var db = new PetaPoco.Database("Data Source=SqlExpress;Initial Catalog=master;Persist Security Info=True;User ID=sa;Password=passwd;Application Name=SQLCC", "System.Date.SqlClient");
        var opName = new SqlParameter("@resName", SqlDbType.VarChar);
        opName.Direction = ParameterDirection.Output;
        opName.Size = 50;
        var opAge = new SqlParameter("@resAge", SqlDbType.Int);
        opAge.Direction = ParameterDirection.Output;
        opAge.Size = 20;
        var s = Sql.Builder.Append(";EXEC OutputDemo @0, @1, @2 OUTPUT, @3 OUTPUT",
           "Markus99",
           99,
           opName,
           opAge
          );
        db.Execute(s);

        System.Console.WriteLine(opName.SqlValue);
        System.Console.WriteLine(opAge.SqlValue);

    }
}

■run it
sqlcc --app.mode=start --action=execute --target="mstest.exe" --targetArgs="/testcontainer:TestProject1.dll" --traceFileName="TraceFile"
sqlcc --app.mode=stop --action=generate --traceFileName="TraceFile"

■result
Type Schema ObjectName FLOC LOC Characters %Covered
PROCEDURE dbo OutputDemo 16 16 301 56.06

Covere show 56.06% ,shoud be 100% I think?
my test case should be passed all code route.

@nickidw
Copy link

nickidw commented Oct 14, 2016

See my fork, I've added some fixes that improves the coverage calculation. Also bear in mind the calculated % is on characters not lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants