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