Kiran - you privately sent me your initial post (not specifying you
cross-posted to the WiX-users list.  I will reply here publicly and in
context with your follow-up.

I personally never have used Lux, as it did not exist when I last developed
a Custom Action of any test-worthy significance (I don't do much installer
work anymore, but when I do usually the WiX set has what I need).  The
value of Lux is certainly there, otherwise Rob and crew would not have made
it!  *The most difficult part of a custom action to test is the immediate
part*, where you likely read the MSI tables or custom tables and properties
and pack all the data you need into a single property.  It
is comparatively simpler to test the deferred/rollback/commit actions using
traditional unit testing methodologies because their interaction with the
MSI APIs are fairly limited (getting the CustomActionData and
MsiFormatRecord/MsiProcessMessage is almost all they can do).

If you write your custom actions with the above fact in mind, testing (and
even debugging via a simple harness) deferred/rollback/commit actions is
quite simple.  In your deferred/rollback/commit actions you write some safe
boilerplate code common to ALL your actions that interact with the MSI API
to get the value of CustomActionData (and mode/language as necessary) and
pass that data off as parameters to another function/entry point in your
Custom Action dll.  Any calls you would make for progress/logging
to MsiFormatRecord/MsiProcessMessage would be conditioned on having a
non-null MSIHANDLE hInstall (which is passed in as NULL in you unit
tests/debugging harness).  Now you can simply test that non-MSI entry point
with some known good packed data and use your traditional unit tests to
validate those results.

In a world without Lux, testing the immediate action that reads
normal/custom tables and properties and creates the packed data structure
really sucks.  Pre-Lux, I had a test harness script that used a manually
created MSI and stuffed a (specially compiled) CustomAction dll into the
binary table and installed the MSI.  The MSI ran the immediate action and
(the normally ifdefed code) wrote the packed data to a file.  The test
harness was responsible for making sure the output file was deleted,
stuffed the dll into the msi, ran the test MSI, compared it with the
expected results, then performed cleanup by uninstalling the test msi (or
running msizap based on its failure state), and deleting the output file.
 That was a royal pain in the ass.  Lux is much better and is designed to
replace that strange ugly test harness.  See the note in the Lux
documentation regarding the Directory properties - this happened to be a
source of pain for my simple testing harness when executing it on (some)
different machines.

So yes, use Lux, but also test using traditional methods to hit your
deferred/rollback/commit actions.  Just be sure to impersonate the
appropriate security context when executing your traditional tests on
your deferred/rollback/commit actions.

Can you sell it to management?  Like any other product you are trying to
sell, you need to be able to enumerate your pain points and show how
investing in unit testing can alleviate them.  If your immediate actions
are drop dead simple (all but a handful of mine are), perhaps you don't
even need Lux, and you should focus on the deferred/rollback/commit
actions.  Unit testing is only as good as the reliability of your test
platform and the data you throw at it.  If nothing else, you can certainly
build test sets with Lux much easier than without, and if you use it
properly (write failing unit tests for cases you have seen that fail before
fixing the bug), you certainly can assure yourself that regressions are
unlikely.

Steve

On Tue, Jul 31, 2012 at 5:26 AM, kirannhegde <kirann.he...@gmail.com> wrote:

> *Getting the infrastructure in place to test custom actions is pretty
> tricky
> (thus Lux exists).*
>
> Could you please elaborate on this?
>
> If i have to sell this idea to my management, what are the  points to make
> out in favour of Lux?
>
> Thanks,
> Kiran Hegde
>
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to