Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

Power Query SDK Unit Testing Error

I am writing a custom data connector using the Power Query SDK in Visual Studio. I have started to write unit tests as per this documentation: https://docs.microsoft.com/en-us/power-query/handlingunittesting . However, I am finding if I have two Facts that call the same function, but with different arguments, I get an error 'Information is needed in order to combine data' and the unit tests won't execute.

 

As an example, the following unit tests will execute correctly as I am calling the same thing twice:

shared MyExtension.UnitTest1= 
[

    facts =
    {
        Fact(   "Test1",
                1,
                Table.RowCount(Data_Connector("Argument1", "Argument2"))
            ),
            Fact(   "Test2",
                1,
                Table.RowCount(Data_Connector("Argument1", "Argument2"))
            )
    },
    report = Facts.Summarize(facts) 

][report];

However, the below will not, now that one of the arguments in the Data_Connector function is different:

shared MyExtension.UnitTest1= 
[

    facts =
    {
        Fact(   "Test1",
                1,
                Table.RowCount(Data_Connector("Argument1", "Argument2"))
            ),
            Fact(   "Test2",
                5,
                Table.RowCount(Data_Connector("SomethingElse1", "SomethingElse2"))
            )
    },
    report = Facts.Summarize(facts) 

][report];

Running the two tests manually in PowerBI returns the expected Table.RowCount results.

 

I have the latest version of Visual Studio and the Power Query SDK.

 

Any thoughts? It's doing my head in.

5 Replies

Replies have been turned off for this discussion
  • v-piga-msft's avatar
    v-piga-msft
    Resident Rockstar

    Hi Anonymous ,

    Do you get error when you run the code in Visual Studio or in Power BI ?

    If it is convenient, could you share the screenshot of the error message so that I could understand better?

    In addtion, maybe ImkeF  has other ideas.

    Best Regards,

    Cherry

     

  • Hi,

     

    Do I have to use Power BI to do unit testing for my project in Power Apps? Is there a way to directly connect Visual Studio's Power Query SDK with the project I created in Power Apps for unit testing? If so, could you provide relevant tutorials?

     

    Thanks.