ORAYLIS
BI.Quality
是一个开源项目,对BI化解方案提供壹种简易的测试方案。它是基于NUnit并援救种种测试方法。以下示例是2010.3.12Release
v1.0版本。

  首先,必要下载安装NUnit,然后安装到位后,打到相应的目录,有一个Lib文件夹,找到里面的BI.Quality.dll。这几个是早就Bulid好的了。有三种艺术来测试,

一种是用NUnit
GUI,展开BI.Quality.dll,然后Run…. 它会自动加载Queries文件夹下的Files,那一个文件包蕴叁体系型,xml是配制文件,sql是用来储存具体查询语句,rslt是结果集文件(这些文件是自动生成,可以去除)。我们打看能够观察是DataSet的XML数据。

  另一个文本夹Connections,是配制连接字符串。分别对应是OLTP,OLAP,MDX的connection.也是依照XML的。内容像这么:

   1:  <Connection>

   2:    <Name>MDX-AdventureWorks</Name>

   3:    <ConnectionString>

   4:      Provider=MSOLAP.4;

   5:      Data Source=.;

   6:      Integrated Security=SSPI;

   7:      Initial Catalog=Adventure Works DW;

   8:    </ConnectionString>

   9:  </Connection>

 

  下边是3个MDX语句的文本内容:

   1:  select 

   2:  non empty

   3:  [Measures].[Internet Sales Amount] on columns,

   4:  non empty

   5:  [Date].[Calendar].[Calendar Quarter].Members on rows 

   6:  from

   7:  [Adventure Works]

   8:  CELL PROPERTIES VALUE;

  

  然后大家来看下要对照查询DW T-sql 语句于另一个文书中:

   1:  select

   2:    'CY ' + cast(dd.CalendarYear as nvarchar) as Year,

   3:    'H' + cast(dd.CalendarSemester as nvarchar) + ' CY ' + cast(dd.CalendarYear as nvarchar) as Semester,

   4:    'Q' + cast(dd.CalendarQuarter as nvarchar) + ' CY ' + cast(dd.CalendarYear as nvarchar) as Quarter,

   5:    cast(sum(SalesAmount)as money )as InternetSalesAmount

   6:  from

   7:     dbo.FactInternetSales fi 

   8:     inner join DimDate dd on fi.OrderDateKey = dd.DateKey

   9:  group by

  10:    dd.CalendarYear,

  11:    'CY ' + cast(dd.CalendarYear as nvarchar),

  12:    'H' + cast(dd.CalendarSemester as nvarchar) + ' CY ' + cast(dd.CalendarYear as nvarchar),

  13:    'Q' + cast(dd.CalendarQuarter as nvarchar) + ' CY ' + cast(dd.CalendarYear as nvarchar) 

  14:  order by

  15:    dd.CalendarYear, 3

 

看NUNIT GUI测试的结果,我们得以见见有四个比较数据测试发现不一样数额:

XML 1
实际这些TOOLS是选择NUNIT的单元测试来测试或相比数据,并且这几个UnitTest动态配制的,能够在SourceCode中来看:

   1:     [Test, TestCaseSource(typeof(ConfigurationManager), "GetTestCases")]

   2:      public void ExecuteQuery(QueryTestConfiguration queryTestConfiguration)

   3:      {

   4:        // get the connection of the QueryTest and check existance

   5:        ConfigurationManager configurationManager = ConfigurationManager.Instance();

   6:        ConnectionConfiguration connectionConfiguration = configurationManager.Connections[queryTestConfiguration.ConnectionRef];

   7:        Assert.IsNotNull(connectionConfiguration, String.Format("QueryTest {1}: ConnectionRef {0} does not exist", queryTestConfiguration.ConnectionRef, queryTestConfiguration.Name));

   8:   

   9:        // Open the connection

  10:        OleDbConnection connection = new OleDbConnection(connectionConfiguration.ConnectionString);

  11:        connection.Open();      

  12:   

  13:        // get the querytext and execute the query and store the rslt in dataTable

  14:        DataTable dataTable = new DataTable();

  15:        String queryText = String.Empty;

  16:        try

  17:        {

  18:          queryText = queryTestConfiguration.Query.GetQueryText(queryTestConfiguration.BaseDir);

  19:          OleDbDataAdapter adapter = new OleDbDataAdapter(queryText, connection);

  20:          adapter.SelectCommand.CommandTimeout = 0;

  21:          

  22:          dataTable.TableName = "rslt";

  23:          adapter.FillSchema(dataTable, SchemaType.Mapped);

  24:          adapter.Fill(dataTable);

  25:   

  26:          CorrectDataTable(dataTable);

  27:        }

  28:        catch (Exception ex)

  29:        {

  30:          System.Console.Out.WriteLine("Query:");

  31:          System.Console.Out.WriteLine(queryText);

  32:          System.Console.Out.WriteLine("Message:");

  33:          System.Console.Out.WriteLine(ex.Message);

  34:          Assert.Fail("Exception ouccured while executing the query: " + ex.Message);

  35:        }

  36:        finally

  37:        {

  38:          connection.Close();

  39:        }

  40:   

  41:        // save the DataTable to File

  42:        if (queryTestConfiguration.RsltFile != null)

  43:        {

  44:          FileInfo fi = new FileInfo(queryTestConfiguration.BaseDir + "\\" + queryTestConfiguration.RsltFile);

  45:          dataTable.WriteXml(fi.FullName,XmlWriteMode.WriteSchema);

  46:        }

  47:   

  48:        // Check Results

  49:        foreach (AssertConfiguration assert in queryTestConfiguration.Asserts)

  50:        {

  51:          assert.AssertThat(dataTable,queryTestConfiguration.BaseDir);

  52:        }

  53:      }

应用了Nunit TestCaseSource
attribute,然后别的那么些配制的XML,全体透过XML体系化实行读取,具体参看SourceCode.

另一种运维方式是选用MsBuild来达成。大家得以写三个bat文件,那样能够应用自动化命令行实施。事先要下载并Install
MSBuild.Community Task。

我们得以看到BIN目录有一个BI.Quality.proj文件,这么些是MsBuild使用的。大家必要做1些配制,例如send
mail,nunit lib src….具体查看MSDN MSBuild.

进度是由此MSBuild去推行Nunit,然后生成XML测试结果,通过NUnitReport.xsl转化成html,然后再send
mail。

Cmd:

XML 2

 

Report:

XML 3

整整正是那么容易,能够看出MSBUILD的强劲。那个动用是SQL SEOdysseyVE福特Explorer二〇〇八 DEMO
database  and dw。

有时间会实际写1些有关细节难点,希望对你有赞助。

Author: Petter liu  http://wintersun.cnblogs.com

相关文章

网站地图xml地图