środa, 31 października 2012

How to create unit test for WIX installer (msi database)

If we want to test installer in WIX technology we can use API from Microsoft.Deployment.WindowsInstaller.dll which is included to WiX Toolset. Below is manual step by step how to test installer database for attached files.

1 Use WiX Toolset v3.6\bin\Microsoft.Deployment.WindowsInstaller.dll and decompile by .dotPeek (it's free) and browse Database class. Now you can execute SELECT query on installer database.
2 Create unit test project, for example for NUnit test framework.
3 Add reference to dll WiX Toolset v3.6\bin\Microsoft.Deployment.WindowsInstaller.dll
4 Create NUnit Test and add to test "Database database = new Database(path to msi, DatabaseOpenMode)
List listFiles = (database.ExecuteNonQuery("select 'FileName' from 'File' ")).Cast().ToList();”

5 Check expected file names in your WIX installer(like .wxs, wxi) with list listFiles. Data could be extracted from .wxs, .wxi by .Net xmlDoc class to read XML and next by foreach to compare file name with above listFiles.

Now you have unit test to check your files names from WIX Installer .wxs,.wxi configuration with compiled installer MSI.
The described unit test How To for WIX is only one of the ideas to test functionality of installer because we can also create unit test for custom actions or use Wix Lux.


dotPeek web site
WIX Lux
Useless WIX unit test example

2 komentarze:

Anonimowy pisze...

Wow, awesome weblog layout! How long have you ever been running a blog for?
you make running a blog glance easy. The entire look of
your website iis magnificent, let alone the content material!

Anonimowy pisze...

Outstanding post, I believe blog owners should larn a lot
from this blog its real user genial. So much superb
information on here :D.