Debugging business logic in AX 2009 SSRS reports

本文介绍如何使用Visual Studio进行AX2009 SSRS报告的业务逻辑调试,通过创建单元测试来验证业务逻辑的正确性,并提供代码覆盖率分析,以缩短调试周期并遵循测试驱动开发原则。

Debugging business logic in AX 2009 SSRS reports

Published 30 August 08 02:43 PM | vnicolas 

Background

With AX2009 you are now able to do SSRS reports in Visual Studio. The typical process for designing a report consist in creating a query and bind to it, code some business logic (BL) specific to the report and design the visual part.

This post will focus on debugging the report business logic. For more information on designing reports in general, see the msdn documentation

There is also an excellent post on Channel 9 from my friend Manoj here.

Debugging

Let say you've designed a fancy report in VS and in order to make it do cool stuff, you had to write some pretty complex business logic. Unfortunately, your business logic does not do what you think it should be doing. You know that you've been working too late on too much caffeine, so you suspect that there might be a bug there and you need to do some debugging.

The 'attach-to-the-server-process' approach

One approach to debug your business logic consist of the following steps

· Rebuild the report in VS in debug mode

· Save it back to the AOD

· Redeploy the report

· Set a breakpoint at a strategic location in your business logic code

· Attach to the server process

· Invoke your report

· Hit the breakpoint and start debugging

While being perfectly valid, this approach has a rather long turn-around-time, especially considering the fact that during a debugging session, you will most likely need to ride the modify-code-rebuild-test carrousel several times.

Also you are an agile programmer and you know about the values of Test Driven Development (TDD), so you are thinking: 'Damn, I wish I had developed this report using the good TDD methods and wrote some unit test for my business logic'. Well, don't despair, Visual Studio (professional edition and above) comes with several cool features that can help you do TDD and debugging on your reports. Let's see how.

Creating unit test for SSRS based reports business logic

Let's assume that you have created your report solution with its related report project

clip_image002

For the sake of simplicity, let's pretend that you have written the following dull BL method

public static DataTable MyMethod()

        DataTable result = new DataTable(); 
        result.Columns.Add("Col1"); 
        result.Columns.Add("Col2"); 
       result.Columns.Add("Col3"); 
        result.Columns.Add("Col4"); 

        return result;
}

Now we are going to create a unit test for this method. But before doing so, we need to help Visual Studio a bit to resolve certain assemblies. In the business logic project, go the reference node, select the Microsoft.Dynamics.Framework.Reports assembly and set the property 'Copy Local' to 'True'.

Then, right-click in the editor and choose 'Create unit test...'. Browse to the folder where the business logic assembly is built (for example <...>/DynamicsReportsLibrary1/DynamicsReportsLibrary1/BusinessLogic/bin/debug/)

and select the DynamicsReportsLibrary1.BusinessLogic.dll assembly. Unfold the tree node and select the method you want to debug as shown below:

clip_image004

You'll notice that Visual Studio will create test project for you if you don't have one. Alternatively, you can create one by right clicking on the solution and choosing 'Add project' and then select the test project template:

clip_image006

Then you can target this project when creating a unit test.

Visual Studio has generated the following unit test method :

[TestMethod()]
public void MyMethodTest()
{
      DataTable expected = null; // TODO: Initialize to an appropriate value
      DataTable actual;
      actual = Report1.MyMethod();
      Assert.AreEqual(expected, actual);
      Assert.Inconclusive("Verify the correctness of this test method.");
} In our example, as we use the DataTable type, we'll also need to add references to System.Data and System.xml in order to get your test project to build. Once you've done that, you should be able to build your solution and run the test. You can either do this from the test toolbar:

 

clip_image008

or from the test view, where you can select each unit test individually.

clip_image010

Now you can start rewriting the auto-generated test and do some real testing. For the sake of simplicity, I'll write a simple test, which checks that the created data table actually has 4 columns.

public void MyMethodTest()
{
      DataTable dataTable = Report1.MyMethod();
      Assert.AreEqual(dataTable.Columns.Count, 4, "The data table must have 4 colums");
}

Running this test provides the following output:

clip_image012

What about Debugging?

That's what we initially wanted to achieve, wasn't it?. Well, that's just a few clicks away. Put a breakpoint at the beginning of your BL method and from the test view window, right-click on the test method and select 'Debug Selection'.

clip_image014

Next thing you know, you are hitting your breakpoint and you can start, debugging your business logic:

clip_image016

Code coverage

As a freebie, you can get Visual Studio to calculate the code coverage for you. Simply edit the test configuration (Tools -> Edit Test Run Configuration -> Local Test Run) to enable the code coverage instrumentation on your BL assembly

clip_image018

Then re-run the test, and click on the 'Show Code Coverage Results' icon in the toolbar of the Test Results window, which will give you the nice view below for free:

clip_image020

Conclusion

The technique described above shows how to debug business logic for SSRS based AX 2009 reports with a quick turn-around time, following the Test Driven Development methodology and providing code coverage measurement on the side. Beware that there might be some scenarios where attaching to the server process is the only way to track a specific bug. Some bugs might only show there ugly faces when the report in running in its deployment context on the server. But if you follow the good principles of TDD and use this local debugging approach, you might not need to go to these extends and you'll likely catch most of the errors at an early stage. Happy debugging :-).

标题基于Flask框架的微博大数据分析与可视化系统实现AI更换标题第1章引言介绍微博大数据分析与可视化系统的研究背景、意义、现状及论文的创新点。1.1研究背景与意义阐述微博大数据分析在信息传播、舆情监控等领域的重要性。1.2国内外研究现状分析国内外微博大数据分析与可视化系统的研究进展与现状。1.3论文创新点概述本文在微博大数据分析与可视化系统方面的创新之处。第2章相关理论介绍Flask框架及微博大数据分析与可视化的相关理论。2.1Flask框架基础阐述Flask框架的特点、优势及基本应用。2.2大数据分析技术介绍大数据分析的基本原理、方法及常用工具。2.3数据可视化技术讨论数据可视化技术的种类、应用场景及实现方法。第3章系统设计详细介绍基于Flask框架的微博大数据分析与可视化系统的设计方案。3.1系统架构设计给出系统的整体架构、模块划分及各模块功能。3.2数据库设计阐述数据库的设计思路、表结构及数据关系。3.3界面设计介绍系统的用户界面设计原则、布局及交互方式。第4章系统实现阐述基于Flask框架的微博大数据分析与可视化系统的实现过程。4.1数据采集与预处理介绍微博数据的采集方法、预处理流程及数据清洗技术。4.2数据分析与挖掘详细介绍数据分析与挖掘的算法、模型及实现过程。4.3可视化展示阐述数据可视化展示的实现方法,包括图表类型、交互设计等。第5章系统测试与优化对基于Flask框架的微博大数据分析与可视化系统进行测试与优化。5.1系统测试方法介绍系统测试的方法、步骤及测试用例设计。5.2测试结果分析对测试结果进行详细分析,包括性能指标、稳定性评估等。5.3系统优化策略提出系统优化的策略,包括算法优化、代码优化等。第6章结论与展望总结本文的研究成果,并展望未来的研究方向。6.1研究结论概括本文的主要研究结论和系统实现效果。6.2展望指出本文研究的不足之处以及未来在微博大数据
内容概要:本文档详细介绍了基于Peng-Robinson状态方程的Matlab代码实现方法,系统性地研究了纯组分与多组分系统的压缩因子(z因子)和逸度系数的计算过程,并进一步拓展至泡点压力与露点压力的确定。该资源聚焦于化工热力学中的核心相平衡问题,通过Matlab编程实现了物性参数的数值求解,涵盖方程求根、迭代算法设计、相态判别等关键技术环节,有助于深入理解实际气体行为及混合物相平衡特性。文档同时展示了该技术在油气工程、化学过程模拟等领域的应用潜力,并列举了多个相关科研方向,体现出其在多学科交叉仿真研究中的支撑价值。; 适合人群:具备化工热力学基础知识及Matlab编程能力的高校学生、科研人员和工程技术人员,尤其适合从事流程模拟、石油天然气工程、反应工程及化工系统优化等方向的硕博研究生与研发工作者。; 使用场景及目标:①开展化工过程中涉及真实气体物性计算的科研项目;②完成化工原理、热力学课程设计或学位论文中的相平衡计算模块开发;③作为Matlab在化工计算中应用的教学案例或实验指导材料;④为复杂多组分体系的工业流程模拟与工艺优化提供算法基础和技术参考。; 阅读建议:建议读者结合经典化工热力学教材深入理解Peng-Robinson方程的理论推导与适用条件,在此基础上通过Matlab代码动手实现迭代求解流程,重点关注初值选取、收敛判断与多重解处理等细节,同时可借鉴文档中提及的相关研究方向拓展科研视野与应用思路。
内容概要:本文系统研究了基于多种智能优化算法(包括布谷鸟搜索CS、大象群体优化EHO、灰狼优化GWO、帝王蝴蝶优化MBO、鲨鱼群算法SSA和粒子群优化PSO)的物联网无人机基站部署问题,重点通过Matlab代码实现对无人机基站的位置优化、通信覆盖范围建模及网络传输性能提升进行仿真分析。研究涵盖了算法对比、路径规划、资源分配与通信效率优化等关键环节,深入探讨了不同智能算法在复杂环境下的收敛性、稳定性与适用性,突出其在提升无线网络覆盖率与系统容量方面的实际应用价值。; 适合人群:具备一定Matlab编程基础,从事通信工程、物联网技术、智能优化算法研究的高校学生、科研人员及工程技术人员,特别适合聚焦无人机通信网络优化方向的硕博研究生与相关领域开发者。; 使用场景及目标:①用于科研项目中无人机基站布局优化的算法选型与仿真验证;②支撑学术论文复现与新型智能优化算法的开发与测试;③为智能算法在无线通信网络中的实际部署提供可运行的Matlab实现案例与技术参考; 阅读建议:建议读者结合提供的Matlab代码逐模块运行与调试,重点关注各优化算法在无人机基站选址与覆盖优化中的实现流程,并可通过调整参数设置或引入新算法开展对比实验,以深化对智能优化机制及其在通信系统中集成应用的理解。
下载代码方式:https://pan.quark.cn/s/a4b39357ea24 **Vue.js 框架全面解析** Vue.js 是一种轻量级且高性能的前端JavaScript框架,因其便捷性、适应性和可扩展性而备受开发者青睐。在“nodejs+vue”的在线购物平台中,Vue.js 主要承担构建用户界面的任务,并提供数据绑定、组件化、路由管理等关键功能。 1. **数据绑定**:Vue.js 的核心优势之一是双向数据绑定,它借助 `v-model` 指令将视图与数据模型建立联系,确保视图层的变动能即时同步到数据模型,同时数据模型的变化也能实时反映在视图上。在在线购物平台中,这一特性可用于商品列表的动态展示和购物车状态的即时调整。 2. **组件化**:Vue.js 提供了功能强大的组件体系,允许开发者将用户界面拆分为独立且可复用的模块。例如,在在线购物平台中,商品展示模块、购物车功能、支付流程等均可封装为组件,从而提升代码的复用性和可维护性。 3. **指令与过滤器**:Vue.js 中的指令如 `v-if`、`v-for` 和 `v-bind` 用于控制元素的渲染方式及行为,过滤器则能对数据进行格式化处理,例如货币显示、时间格式转换等。在在线购物平台中,这些功能有助于更有效地展示商品信息并优化用户交互体验。 4. **计算属性与侦听器**:计算属性能够监测多个数据源并输出计算结果,而侦听器则能在数据变动时执行指定操作。在在线购物平台中,计算属性可用于自动计算购物车总金额,侦听器则可响应库存变动并实时更新商品状态。 5. **Vue Router 路由管理**:在单页应用(SPA)环境中,Vue Router 是不可或缺的组件,它负责管理页面间的导航和...
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值