Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CRM Online 2011 Integration Testing running in Production environment

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:

  1. upload the plugin
  2. create a contact
  3. hit save
  4. 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

like image 672
Ruben Bartelink Avatar asked Nov 26 '25 15:11

Ruben Bartelink


1 Answers

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!

like image 91
Peter Majeed Avatar answered Dec 01 '25 03:12

Peter Majeed



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!