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>

 

  下面是一个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文件,这个是MsBuildXML使用的。我们要开片配制,例如send
mail,nunit lib src….具体查看MSDN MSBuild.

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

Cmd:

XML 2

 

Report:

XML 3

漫就是那简单,可以看到MSBUILD的有力。这个动用是SQL SERVER2008 DEMO
database  and dw。

出日会具体写一些有关细节问题,希望对你发出帮助。

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

相关文章

网站地图xml地图