Easy peasy emails from SoapUI test cases to you

As a sophomore-level programming autodidact, I’m on an ongoing quest to bootstrap my test automation with SmartBear‘s venerable SoapUI. You can script SoapUI as heavily as you want to with the Groovy programming language. Or you can use SoapUI’s built-in GUI elements to reduce your programming work. For example, it can be a simple matter to let SoapUI consume your project WSDL and build out a request for you… and then display the incoming response in an easy-to-read form. Or you can use groovy-wslite to start you off on the same road, but it may take you longer to write the code yourself and might not yield you any richer results.

I really wanted SoapUI to email me a simple text message when a test ended. I’d already written and tested a Groovy class that used Apache Commons’ multipart email capabilities. However, I wasn’t sure how to use that class in SoapUI. After some Googling and experimenting, here’s how I got the whole thing working today.

  1. I pointed SoapUI’s script library to the folder that contained my .groovy file with the class definition.* The sixth entry on the right in the image below takes a folder location.
    Inline image 1
  2. I dropped the Apache commons.email jar into $SoapUI_home/bin/ext, otherwise known as the bin/ext directory in your SoapUI installation folder.  (Hat tip to Saurabh Gupta for this pointer.) I would imagine that putting it into $SoapUI_home/lib would work just as well, since that’s where the SoapUI installer puts a lot of the other Apache libraries.
  3. For this test case, I wanted to record all my pass/fails and email myself at the end. So I put the following code into the setup script for the test case. The setup script window is visible at the bottom of the test case GUI in SoapUI.
    context.scriptResultsList = [] // List to hold pass/fails
    context.email // to be initialized later
  4. Later in the test case, a Groovy script checks one XML file against another and records “PASS” if they’re identical, “FAIL” if not, and adds the “PASS” or “FAIL” string as a list item to the scriptResultsList context variable defined in the test case setup script.
    if (xmlDiff.identical()) {
       scriptResult = 'PASS'  
     else {
       scriptResult = 'FAIL'
    context.scriptResultsList << scriptResult
  5. In the teardown script for the test case, I call my email class by attaching it to the context.email variable I created in the setup script. I send an email whose text depends on whether any of my test cases failed. I could attach a results file with a little more work.
    if ( context.scriptResultsList.find {it == 'FAIL'} ) {
    context.email = new ApacheMultiPartEmail("", "", "", 
    "Failure: SoapUI Regression Test", "At least one of your 
    test runs failed. Check detailed results.", 
    else {
    context.email = new ApacheMultiPartEmail("", "", "", 
    "Pass: SoapUI Regression Test", 
    "None of your test runs failed.", 

* Here’s my email class definition, which closely resembles the example in the Apache Commons online docs. It was written to send emails via an Exchange SMTP server. Note that Apache Commons also offers a SimpleEmail class that would have worked just as well for this limited purpose.

import org.apache.commons.*;
public class ApacheMultiPartEmail {
public ApacheMultiPartEmail(attPath, attDescription, attName, msgSubject, msgMessage, msgRecipient) {
if (attPath != '' && attDescription != '' && attName != '') {
EmailAttachment attachment = new EmailAttachment();

Email email = new MultiPartEmail();
email.setHostName("smtp.yourhostname.org"); // I hardcode this
email.setSmtpPort(yoursmtpport); // also hardcoded in the class definition
email.setFrom("desiredSenderEmailAddress"); //I hardcode this value in the class always to send the message from me. You could pass it in as a parameter too. 


A fine balance: introversion, leadership, and being a good team member

I recently finished Susan Cain’s excellent book Quiet: The Power of Introverts. For me, an introvert’s introvert, the book confirmed some things I already knew and gave me some new things to think about. It’s dispiriting that American business culture still gives so much credence to the fast talker: in fact, according to studies Cain writes about, big talkers are commonly perceived as being smarter than those who have less to say. (This appears to be a cultural limitation: Cain writes about how some Asian cultures still prize the quiet, studious, family-oriented person.)

I often sit back and observe software team meetings: on my current team, the lead developers appear to be more introverted than the business SMES and analysts, and unless they are given an opportunity to speak they typically won’t do so. I am the lead tester on the team, and a technically-inclined woman as well, and I generally act contrary to my introverted nature in meetings. I’ll speak up unsolicited and offer my opinion if I think it’s warranted. I’ve learned the hard way that unless you speak up in such a meeting, you’re likely not to have an opportunity to be heard. 

It’s even more interesting when you often have something to say because you see something that is off or wrong, or that could simply be improved. I found out recently that the itch for change is part of my nature too. My company recently offered an “influencing skills” workship in preparation for which we each took a DiSC personality assessment. I tend to be more than a little skeptical of personality assessment tests — confirmation bias ahoy. But it was fascinating to watch as we broke down into our DiSC groups and each group tended to behave in accordance with DiSC expectations: the S’s took twice as long to arrive at a decision as anyone else, while the D’s (that was my group) had no trouble making quick decisions.  According to the DiSC approach, D’s tend to want to change things and do so quickly. (As I said to one of my fellow D’s, “D is for diva.”) I identified right down the line with the approach’s description of the D (again, note to myself, confirmation bias ahoy). So I appear to be a Dominant and also an introvert who is all too aware of the cultural bias against introverts. Try sitting still with that at a meeting.

Cain writes about Free Trait Theory as a possible explanation of seeming contradictions in our natures. Simply put, we contain multitudes as did Walt Whitman. You have introverts who are splendid and beloved lecturers, organizational leaders, and actors. But they can’t play those roles for too long: after a few hours in the public eye, you’ll see them running off to their private office whose door they close, and they stay there for quite a while, perhaps with a pet and a radio as their only company. 

What does all of this mean for being a technical test lead for a project? It means that I have to reconcile my innate tendency NOT to speak up against my contrary tendency to want to announce Things That Are Broken That Need Fixing. For reasons I won’t go into here, I believe I went a little too far down the Jeremiah lane this week; however, I did act ethically on the best information available to me at the time. And my actions led to a group initiative to do further exploration of the issue: getting more information on a subject can never hurt. But there’s a time and place for everything. It’s trial and error for anyone who is in a leadership role to know when to sit back, shut up, and listen, and when to speak up. (Mentoring helps. A lot.)