问题
I'm writing some code for Dynamics CRM Online 2011.
I'd like to have a set of integration tests be run in CRM Online and be able to examine:
- Some log output
- Assertion failures
Under the control of a test runner on my local machine.
Right now, I'm doing:
var passes = new List<string>();
var fails = new List<Tuple<string,Exception>>();
foreach(Action<StringWriter> testAction in EnumTests())
{
var log = stringWriter();
try
{
testAction(log);
passes.Add(log.ToString());
}
catch(Exception e)
{
fails.Add(log.ToString(),e);
}
}
throw new Exception( "PASSES: " + string.Join("======", passes.ToArray())
+ "FAILS: " + string.Join("=======",fails.Select(f=>f.ToString()).ToArray());
I trigger this code by plugin action wired to Contact Create:
- upload the plugin
- create a contact
- hit save
- download the exception data file
There has to be a better way but I simply cannot find any reference within the docs or blogs or forums) to triggering plugin code via a test (and getting exception output).
I want to be able to call a method in the plugin and then have the results including a full stack trace and log output arrive back within the context of a xUnit test.
Is that possible? Have others done anything similar? Surely not all CRM 2011 devs are stuck in a whackamole with a mouse loop?
NB I'm not interested in debugging on premise and ideally would prefer not to have to store results into bespoke entities. I know I could screenscrape the page but am hoping there's some way I can do the equivalent of a webservice call. Or that someone has a nice framework that simply does it all (or I can tweak).
EDIT: Looks like I'll probably end up asking whether anyone has some nice WatiN code against CRM Online next
回答1:
I'm not sure I understand everything you're looking to accomplish, but I'm betting based on your comment that you've already had a look at CRM 2011 Plugin Testing Tools on codePlex. As the Project Description and Release Notes both mention that a MS employee helped develop that project, you can quickly see that MS's support for what you're asking for is limited.
As Jon C mentioned, Josh Painter mentioned in an answer to another question that there's a built-in plugin-debugger you can use, which would be executed on the client machine.
Also, Erik Pool posted on his blog a great entry on manually instantiating a IPluginExecutionContext
for your plugins.
Hope one of these three solutions works!
来源:https://stackoverflow.com/questions/8488105/crm-online-2011-integration-testing-running-in-production-environment