usql应用程序和脚本的单元测试 [英] Unit testing for usql applier and scripts
问题描述
我有一个自定义的USql应用程序,该应用程序扩展了IApplier
类.
I have a custom USql applier which extends the IApplier
class.
[SqlUserDefinedApplier]
public class CsvApplier : IApplier
{
public CsvApplier()
{
//totalcount = count;
}
public override IEnumerable<IRow> Apply(IRow input, IUpdatableRow output)
{
//....custom logic
//yield return or yield break
}
}
然后将该应用程序从Usql脚本中用作
This applier is then used from Usql script as
@log =
SELECT t.ultimateID,
t.siteID,
.
.
.
t.eTime,
t.hours
FROM @logWithCount
CROSS APPLY
new BSWBigData.USQLApplier.CsvApplier() AS t(ultimateID string, siteID string, .... , eTime string, hours double, count long?);
我已经能够为应用程序的分离部分编写单元测试/ATP.
I have been able to write unit tests/ATPs for decoupled parts of applier.
如何为Apply
方法的C#代码和依赖于输入/输出的自定义逻辑编写测试?
如何使用定义的输入和输出自动执行usql脚本测试,从而不需要数据湖帐户?
How can i write tests for C# code of Apply
method and the custom logic dependent on input/output?
How can i automate testing of usql scripts with defined inputs and outputs such that no data lake account is needed?
推荐答案
在我们发布独立的U-SQL Localrun SDK程序包之前,请从安装VS的ADLA工具的位置获取所需的文件.
Before we ship the standalone U-SQL Localrun SDK package, please get the needed files from where you installed the ADLA Tool for VS.
在VS2015中,本地运行所需的所有依赖项都位于"C:\ Program Files(x86)\ Microsoft Visual Studio 14.0 \ Common7 \ IDE \ Extensions \ Microsoft \ Microsoft Azure Data Lake DRI Tools for Visual Studio 2015 \ 2.0 .XXXX.0 \ LocalRunSDK.您还将需要"C:\ Program Files(x86)\ Microsoft Visual Studio 14.0 \ Common7 \ IDE \ Extensions \ Microsoft \ Microsoft Azure Data Lake DRI Tools for Visual Studio 2015 \ 2.0.XXXX.0 \ CppSDK"
In VS2015, all the dependencies needed for local run are in "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Microsoft Azure Data Lake DRI Tools for Visual Studio 2015\2.0.XXXX.0\LocalRunSDK. You will also need "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Microsoft Azure Data Lake DRI Tools for Visual Studio 2015\2.0.XXXX.0\CppSDK"
只需从这两个文件夹中复制文件,然后将它们放置在类似的位置:
Just copy files from these two folders and place them somewhere like:
C:\ USQLLocalRunSDK
C:\USQLLocalRunSDK
然后,您可以使用"LocalRunHelper.exe"在本地编译和运行u-sql脚本.在编译命令行上,您需要两个选项: -DataRoot本地元数据和数据的存储位置",与ADLA工具中的设置选项相同. -CppSDK您在何处复制了CppSDK文件" 该工具将在错误(编译或运行)时返回-1,并在成功时返回0.
Then you can use "LocalRunHelper.exe" to compile and run your u-sql scripts locally. On the compilation commandline, you need two options: -DataRoot "Where your local metadata and data are stored", the same as that setup option in ADLA Tool. -CppSDK "Where you copied the CppSDK files" That tool will return -1 upon error (compile or run) and 0 on success.
只需运行该工具即可查看命令行选项列表.
Just run the tool to see the list of command line options.
这篇关于usql应用程序和脚本的单元测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!