Houzz.com

Android Code Coverage with JaCoCo

At Houzz, we use automatic testing to ensure that the Houzz App is stable and bug free. With time, the automation test suite has gotten larger, and more comprehensive. As developers, we wanted to measure how much of our code is being tested and to understand what scenarios are accounted for, which not, and what additional automated testing to add. To do this, we used Code Coverage. It is common practice to use Jacoco on Android, specifically, but it’s integration into Jenkins and a continuous integration system is far from simple.

In this article, I will demonstrate how to integrate code coverage into Jenkins automated continuous integration using a simple Android app. The full code of this post can be found on github.

Simple Demo Project

I made an app that contains a screen with one button. Clicking on the button causes the text to appear.

image

Unit Testing

To test this app, I chose to use the Espresso framework. This framework is the official framework for Android unit testing. Other frameworks that can be used include Robotium and UIAutomator.

The scenario covered by the test is that a click on the “Hello World!” button causes the “I am alive!” text to appear.

Here is the code:

@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {

    @Rule
    public ActivityTestRule mActivityRule = new ActivityTestRule(MainActivity.class);

    @Test
    public void checkButton() { 
        onView(withId(R.id.button)).perform(click());
        onView(withId(R.id.textview)).check(matches(withText(R.string.i_am_alive)));
    }
}

Running this code makes a click on the button and, once the text is verified to match the required test, the text to appear.

Adding Code Coverage

Now for the code coverage. To add the code coverage to the app we need to add this line to the build.gradle:

buildTypes {
    debug {          
        testCoverageEnabled true
    }
}

This will add the code coverage to our code (done automatically).

Another line we should add is the version of JaCoCo that we want to use. I chose the 0.7.5.201505241946 version because the JaCoCo plugin for Jenkins is configured to use this version (at the date of writing this post).

apply plugin: 'jacoco'
jacoco {
    toolVersion = '0.7.5.201505241946'
}

Building

When running a UI test on the emulator or device the gradle builds two apk files, one for the app, and one for the testing code. Let’s build both the app and the testing app and install them.

First connect a device or an emulator, and type in the command line in the project folder:

./gradlew clean installDebug installDebugAndroidTest

This command will:

  • clean the build folder
  • compile and install the app on the device
  • compile and install testing app on the device

Running Test with Code Coverage

Now for the fun part. Run the tests from command line:

adb shell am instrument -w -r -e coverage true  -e debug false -e class houzz.com.hellojacoco.ExampleInstrumentedTest#checkButton houzz.com.hellojacoco.test/android.support.test.runner.AndroidJUnitRunner

Let’s explain the above command first:

  • “adb shell am instrument -w” runs all the UI tests
  • “-e coverage true” tells the runner to run the UI tests in a code coverage mode. By default, the code coverage results file will be saved in a /data/coverage.ec file, unless overridden by coverageFile flag.
  • “-e debug false” is because we don’t want to debug the testing
  • “-e class houzz.com.hellojacoco.ExampleInstrumentedTest#checkButton houzz.com.hellojacoco.test/android.support.test.runner.AndroidJUnitRunner” this tells our app to run a specific test

Learn more about running tests from command line here.

An example output is:

INSTRUMENTATION_STATUS: numtests=1
INSTRUMENTATION_STATUS: stream=houzz.com.hellojacoco.ExampleInstrumentedTest:
INSTRUMENTATION_STATUS: id=AndroidJUnitRunner
INSTRUMENTATION_STATUS: test=checkButtonINSTRUMENTATION_STATUS: class=houzz.com.hellojacoco.ExampleInstrumentedTestINSTRUMENTATION_STATUS: current=1
INSTRUMENTATION_STATUS_CODE: 1
INSTRUMENTATION_STATUS: numtests=1
INSTRUMENTATION_STATUS: stream=.
INSTRUMENTATION_STATUS: id=AndroidJUnitRunner
INSTRUMENTATION_STATUS: test=checkButtonINSTRUMENTATION_STATUS: class=houzz.com.hellojacoco.ExampleInstrumentedTestINSTRUMENTATION_STATUS: current=1
INSTRUMENTATION_STATUS_CODE: 0
INSTRUMENTATION_RESULT: stream= 
Time: 1.621
OK (1 test)
Generated code coverage data to /data/user/0/houzz.com.hellojacoco/files/coverage.ec
INSTRUMENTATION_RESULT: coverageFilePath=/data/user/0/houzz.com.hellojacoco/files/coverage.ecINSTRUMENTATION_CODE: -1

The output of this whole process is represented as a “raw” file that stores the coverage results file - coverage.ec. Notice at the end of the output of the command to the next line:

Generated code coverage data to /data/user/0/houzz.com.hellojacoco/files/coverage.ec

You won’t find it if you search in your computer. That is because this file is saved on the device. We need another command to pull the file from the device.

adb pull /data/user/0/houzz.com.hellojacoco/files/coverage.ec

Using the Coverage File

Now we have a binary file, and in our case it’s 4.0K in size. But what should we do with it?

This is the part where most developers get stuck. I dived into the Jacoco projects code and found a ReportGenerator.java file. This class generates a report for an Eclipse project style, so I changed the code a bit and exported a jar that will fit our needs.

Executing the jar is simple:

java -jar android-jacoco-the-missing.jar -f /path/to/coverage.ec -p ./hellojacoco

And it will generate a folder named coveragereport/ one level above project’s folder. (this can be changed with the -r flag)

So let’s dive into it and see the report in the index.html file:

image

What we see here is the package of our app. When we dive in we can elaborate on specific code coverage metrics. Clicking on the link brings you into:

image

Here are all the classes that we tested. One is the main activity, while the second is an anonymous class of a OnClickListener. We can see that we have a 90% coverage. Clicking on the MainActivity link gets us into:

image

What we see here is all the line that the test visited highlighted in green. If a line is not covered it is highlighted in red. If a “if” clause is passed with one result (true or false) it is highlighted with yellow color.

Using the Jenkins Plugin

For those who use Jenkins as part of their building process, there is a another option in order to process the coverage binary file. In this case you can install the JaCoCo plugin for Jenkins. After installing it, you need to configure it in the project. We need to go to the post build section and add “Record JaCoCo coverage report”:

image

I recommend to add this line to the exclusions section:

 **/R.class,**/R$_.class,__/BuildConfig._,_<em>/Manifest_.</em>,_<em>/_Test</em>._,android/__/_.

This will make android ignore those generated files.

And now you have a code coverage integrated into your Jenkins build system. You will now be able to monitor your test coverage and determine which features need more testing. Happy testing!

Watch My Houzz, Featuring Actor Kristen Bell’s Surprise Renovation



We are excited to share the latest episode of “My Houzz,” a video series that follows people as they renovate the home of someone meaningful to them, starring actress Kristen Bell. The episode follows Kristen as she surprises her sister, Sara, with a major basement renovation to create a beautiful, functional space for her and her family.

Kristen used Houzz to pull off the surprise remodel in Michigan from her home in California, including finding a local professional with great reviews, sharing ideas for her sister’s dream home, and buying all the furniture and accessories from the Houzz Shop.

This episode follows the success of the My Houzz pilot featuring Ashton Kutcher, who secretly remodeled the basement of his family home in Iowa. The 2017 series includes five episodes that will premiere in the first half of the year. Each episode documents a well-known, public figure as they surprise a close family member that made a difference in their life with the gift of a renovation, using Houzz throughout their journey.

Grab some popcorn and watch the video here. You can also learn more about the design, shop the look from the renovation and check out Kristen’s Houzz profile.

Houzzer Profile: Mark Mao, Research Scientist

image

As a research scientist, Mark strives to solve challenging computer vision problems at Houzz with cutting edge deep learning algorithms. When he’s not at work, he can be found spending time with his family, playing tennis or jogging.

When did you first discover computer science?
When I was a second grader, I joined my school’s computer club. We learned how to program with BASIC. I loved computers and have been programming ever since.

How did you get into deep learning?
I started my career as a software engineer, but really enjoyed doing research. So, I went back to school for my PhD at Stanford in Electrical Engineering, which led me to machine learning. I was a believer in deep neural networks early on when I worked on speech recognition several years ago. The improvement achieved in that area with deep neural networks was breathtaking. The same is also true for computer vision problems I am working on at Houzz now. This is really an exciting time for AI.

What is the best part about working at Houzz?
The best part is getting to work with many very smart and talented co-workers. Everyone at Houzz has a single-minded focus on creating products that give our users the best experience possible.

What do you enjoy most about your role at Houzz?
I enjoy doing research and getting to work on very interesting computer vision and machine learning problems at Houzz. I also enjoy the fact that whenever I make good progress, I get to see the impact on our users’ experience immediately.

What’s your favorite thing you’ve worked on at Houzz?
Visual Match - a tool that detects and classifies objects in photos on Houzz and finds visually similar products from the Houzz Marketplace. Deep learning is an area that’s advancing very fast. It’s really interesting and rewarding to put it to work to solve real problems at Houzz.

What’s something that has surprised you about working at Houzz?
The people at Houzz are so much fun to be around. People feel like close friends and family here. It may sound like a cliche, but it’s 100% true.

What do you do when you’re not working?
I spend a lot of time doing fun things with my two daughters. For the small amount of time I have for myself, I like playing tennis and jogging. I also enjoy traveling with my family.

How have you used Houzz at home?
Yes, that’s how I first got to know Houzz. My wife and I started a renovation in 2012 and were looking for professionals. We found our architect for the project on Houzz, then used it for ideas throughout the remodel of two bathrooms and a living area. Now, we’re using Houzz for an exterior update. Our house is an ongoing project.

What’s Driving the Home Improvement Industry Boom?

According to most leading industry trackers, the home improvement industry has surpassed its prerecession peak in 2016 and is on track to continue its expansion in 2017.1 These trends are born out in our 2017 Houzz State of the Industry study, where a third or more of businesses on Houzz report that 2016 was the best year in the last 10 years since the 2007 financial crisis and two thirds report that 2016 was an above average year. Revenue continued to grow at an average rate of 7-10% across the industry groups in 2016 and expectations for 2017 revenue growth are high.

image

Our research points to three key factors that are propelling the industry growth today.

Growth Driver #1: Aging Housing Stock
According to the 2015 Houzz and Home survey of homeowners on Houzz, 52% of homes were built before 1981 and only 19% were built after 2000.2 This is consistent with 2015 government data that show that a median home was built in 1976,3 i.e., is 39 years old. Older homes require a vast array of replacements and repair, from updating home systems, such as electrical wiring or panels, to upgrading exterior building features, such as weathered roofing or siding. These homes also tend to be smaller, prompting homeowners to add more square footage. Finally, homeowners are apt to upgrade the outdated style, features, and/or appliances in older homes by remodeling kitchens and bathrooms (e.g., a median kitchen and bathroom is updated every 25 and 23 years, respectively4) and other living spaces.

Growth Driver #2: Older homeowners
According to the U.S. Census, the average homeownership rate was 64% in 2016,5 with 37% and 44% of homeowner households concentrated in the 35-54 and 55+ age groups, respectively.6 This is a critical trend for the home renovation industry, as older and more established households are the biggest spenders on home improvement. For example, according to the 2016 Houzz and Home study, homeowners in the 35-54 and 55+ age groups spent, an average, $52,100 and $73,300 on 2015 home renovations, respectively, compared to only $24,500 by those under 35.7 Older homeowners have a greater propensity to spend on home improvements, as they earn greater income and/or have greater savings than younger households. They are also more likely to remain in their current home for more than a decade.8

Growth Driver #3: Strong Consumer Confidence
Consumer confidence is a major indicator of how likely consumers are to spend on goods and services, and consequently is an important indicator for the home improvement industry. 2016 closed at the highest levels in 15 years, with the Conference Board index reporting 113.3.9 Consumer confidence is rooted in home prices and job market conditions, among other factors. It helps that home prices have fully recovered relative to the prerecession peak on a national level,10 propping up home equities. Furthermore, the unemployment rate has returned to the pre-recession low levels of 4.6-4.7% and the economy has been gaining jobs for the past seven years in a row.11

All in all, the combination of professional and consumer optimism and aging homes and population will be key to continued industry growth. That said, a number of factors are holding the industry back, including lagging existing home sales, declining homeownership rates, and severe labor shortages. We, at Houzz Research, continue to watch and estimate the extent to which these factors are impacting the industry. Stay tuned.

1 Harvard Joint Center for Housing Studies, Remodeling Futures Group, October 2016 Presentation; Hanley Wood MetroStudy Q3 2016 Release, HIRI RnR Estimates Reported in Goldman Sachs, Americas: Capital Goods, 2017 Outlook.
22016 Houzz and Home Study, p. 44.
3American Housing Survey 2015.
42015 Kitchen Study, p. 11 and 2015 Houzz Bathroom Study, p. 8.
5U.S. Census, Release Number C17-05.
6American Housing Survey 2015.
72016 Houzz and Home Study, p. 44.
82016 Houzz and Home Study, p. 7.
9The Conference Board, Consumer Confidence Index
10S&P CoreLogic Case-Shiller U.S. National Home Price NSA Index, November 2016.
11 U.S. Bureau of Labor Statistics, Current Population Survey - Unemployment and Job Report.

An Update on Our Global Expansion

image

There are two main criteria we look at when evaluating new markets for Houzz: one is strong local demand for the Houzz offering and the second is demand from the global Houzz community in a market’s design aesthetic and expertise. We’re thrilled to announce the launch of our localized platform for India (houzz.in) this week, a market that stands out on both fronts.

Over one million Indians are already using Houzz every month to find design inspiration, get advice from the largest home community on the web, source products, research and hire home professionals, and manage home projects from start to finish. Indian trade professionals are already active on Houzz as well, with over 50,000 home professionals using the site to showcase their work, build their brands and reach new clients. None of the other countries we have launched to date have had such a large professional community to start.

With India, Houzz now has localized platforms and apps in 14 countries outside of the U.S.: UKAustralia, Germany, France, Russia, Japan, Spain, Italy, Denmark, Sweden, New Zealand, Ireland and Singapore. We’re seeing our community of homeowners and home professionals grow tremendously around the world, and today we have over 40 million monthly unique users and over 1.5 million active home renovation and design professionals in more than 60 categories such as landscape designers, builders, contractors, architects, interior designers and more. While in 2013, prior to our international expansion, less than 30% of new Houzz users came from outside the U.S., over 45% of new Houzz users do so today. 

This growth has translated to our business as well. In 2016, we began expanding our Pro+ local marketing program and subscription service for home professionals outside of the U.S. to meet the demand from our professional community. Today, Houzz Pro+ is available in 150 markets across six countries outside of the U.S.

While the growth of our community and business internationally has been significant, one of the things that excites us the most about our expansion is the opportunity to facilitate a global design language. We’ve seen how excited people are to see inspirational projects, guides and articles written by experts all over the world, as well as to have access products, materials and professionals that are completely aligned with the vision they have for their homes. Nearly three percent of projects received by design pros via Houzz in 2015 were outside of their country, and we can only expect to see more of this cross-border activity in the future.

There’s a lot more to come in 2017, and launch of Houzz India is a great way to start off the new year. 

New Kitchen, Healthier Lifestyle

image

A new kitchen might do more for your home than you think.

A third of respondents in our U.S. Houzz Kitchen Trends Study of more than 2,700 U.S. homeowners using Houzz who are in the midst of, are planning or recently completed a kitchen renovation project, said that they are leading healthier lifestyles after their kitchen renovation.

Forty-one percent said they cook more meals at home (three-quarters cook five or more meals at home each week after renovating!) and 34% said they order less take out. Twenty-six percent of respondents also said they eat more fruits and vegetables after upgrading their kitchen.

Other lifestyle changes? Nearly half of respondents said they enjoy more family time (49%) and 40% say they entertain more. Perhaps one downside to having a more functional kitchen: 32% say they work from home more post-renovation.

For more insights from the 2017 U. S. Houzz Kitchen Trends Study, check out the full report here.

A Tasty Competition

To kick off the holidays, teams at Houzz HQ in Palo Alto competed the 2nd Annual Gingerbread Houzz Competition.

Houzz founders Adi and Alon were the distinguished judges. While they could agree on the winner – the whimsical “Up” Houzz by the Infrastructure team – they were so divided on the runner up that they awarded all other entries “second” place.

image

Here are a few of our favorites.

image

The Editorial team took the tiny house route with this house in a jar

image

One of the many engineering teams to participate used the Saint Petersburg Mosque as a source of inspiration, adding our unofficial mascot (the rubber ducky) outfront

image

It’s hard to tell from the photo, but this gingerbread house by the Data Operations team was outfitted with stained glass windows

image

“Our style this year was ‘Minimally Tasteful,” said Doug Durando of this house by the Industry Marketing team. “We brought it to life using dried orange slice shingles, dragée gum subway tiles, and a loose-leaf tea living wall. The latter feature gave the house a pleasantly floral scent, activating a sense often overlooked in gingerbread house competitions.”

We take gingerbread home decorating quite seriously!

Deck the Halls with LOTS of Holly

image

What’s in store for holiday decorating this year? A survey of U.S. Houzzers found that one in six holiday decorators plan to go “over the top” (16%). Another 60% describe their décor style as “festive” and 22% take a “minimalist” approach. Making things merry and bright doesn’t mean breaking the bank, however. The majority of holiday decorators plan to spend less than $50 on new items this year.

image

Holiday décor isn’t just about seasonal sprucing. Sixty percent of survey respondents expect to host overnight guests this holiday season. Of those, one-quarter plan to redecorate a guest bedroom and/or bathroom (25%), and one in ten plan to renovate (10%). Making sure the fridge/pantry is stocked and deep cleaning the house top hosts’ to do lists (87% and 78%, respectively).

image

While the jury’s still out on whether or not Santa is real, the survey revealed that the majority of Christmas trees are not. In fact, artificial trees are twice as popular as real ones (72% vs. 35%, respectively). Candles top the list of must have holiday decor and will make appearances in four in five homes (83%).

Nearly half of respondents reported that pulling their decor out of storage is the most stressful part of the holiday decorating process (44%). Perhaps in an attempt to curb this stress the following year, nearly one in five report that donating/throwing away decor they no longer want is their favorite part of the holiday decorating process (18%).

Wishing everyone a very happy holiday season!

What’s in a Custom Home? Room for Recreation, Most Likely

image

New data released from the 2016 U.S. Houzz & Home survey found that over two-thirds of homeowners on Houzz (68 percent) plan to include a recreational area in their newly-built custom home. The most popular rooms for fun? Gaming and entertainment rooms top the list with appearances in over one-quarter of custom built homes (29 percent), followed by home gyms (22 percent), libraries (18 percent), home theaters and kids’ playrooms (both 17 percent). Kids playrooms are especially popular among Millennials (38 percent) and Gen Xers (24 percent).

This customization is just what people crave with nearly half of homeowners opting to build versus buy because they have a specific vision for what a home should be (48 percent). While the majority of those building a custom home use custom drawn plans (62 percent), a significant number also use ready-made plans that they modify (32 percent). For most homeowners, building a dream home means staying put for the long-term, and this increases with age. Forty-six percent Millennials, 51 percent of Gen Xers, and 59 percent of Baby Boomers say they have no plans to ever move from their custom home.

While achieving a specific vision for a home is a key motivation to build, over a quarter of Millennials opt to build because of greater affordability (26 percent) versus just 11 percent of Gen Xers and seven percent of Baby Boomers. In keeping with this, Millennial homeowners spend significantly less on custom home building than their older counterparts. While the average spend on custom home construction for those who completed projects in 2015 on Houzz was $942,000, Millennials spent an average of $423,100, followed by Gen Xers at $714,300, and Baby Boomers at $1,168,600.

More than half of those who finished a custom home build in 2015 went over budget (53 percent). Choosing more expensive products or materials is the leading budget buster (63 percent), followed by products or services being more costly than expected (44 percent), and changing the product scope or design (30 percent). When it comes to financing, more than half of new custom home builds are funded by savings/personal finances (56 percent), followed by construction loans secured by the home’s value (44 percent).

Between customization and the large investment for a forever home, it’s no wonder that the vast majority of homeowners hire professionals to help with their project (95 percent). Builders top the list (63 percent), followed by architects and general contractors (both 38 percent). Many homeowners hire specialists for their projects as well, including electricians (55 percent), cabinetry specialists and plumbers (both 49 percent).

The average custom built home features three bedrooms and three bathrooms. Baby Boomers are most likely to build a single-story home (39 percent versus 28 percent for Millennials and 25 percent for Gen Xers). Meanwhile, more than one-quarter of Gen Xers (27 percent) and nearly the same number of Millennials (25 percent) are building homes with three or more stories.  

The Houzz & Home Survey was sent to registered users of Houzz and fielded in March-June 2016. The Farnsworth Group, an independent market research firm, conducted the survey. Among the more than 120,000 survey respondents in the U.S., more than 6,500 are in the midst of, are planning, or have recently completed a new home build. Check out the full report at http://info.houzz.com/HH2016.html.

*Custom home building challenges based on the 2015 U.S. Houzz & Home survey.

Houzzer Profile: Mindy Weng, Front-End Engineer

image

Mindy focuses on building the user interface for Houzzers as a front-end engineer, from enhancing the photo browsing experience, to redesigning user profiles, to creating a home for Houzz TV. When she’s not at work, she can often be found hiking with her husband and her Shiba Inu, Maui, or tackling a remodeling project at home.

What sparked your interest in computer science?
I was really into art when I was growing up in Taiwan – I’ve always enjoyed making things, from sewing to craft projects. When I was in a high school computer class, I learned Flash to make simple animated games. That’s when I discovered how fun it is to create something using a computer. I enjoyed it so much that I decided to study computer science in college, and then grad school. This is also why I wanted to become a front-end engineer, specifically – I enjoy building things that people can see and interact with.

Why did you decide to join Houzz?
In addition to computer science, I also love interior design. My husband and I were actually in the process of purchasing our home at the time – an Eichler – and thinking about how we would make it our own. Working at Houzz has given me a great opportunity to put both of these interests to use.

What’s your favorite part of working at Houzz?
The people and the culture. For the first time in my career I feel like I work with friends, with family. People like to help and influence each other here, like a friend or a family member would. We support each other, and we learn a lot from each other every day.

We also have a lot of fun together. For instance, decorating our desks with rubber duckies is a Houzz tradition we all love.

What’s something that has surprised you about working at Houzz?
We have a lot of freedom to drive our own projects at Houzz. This hasn’t changed in the four years that I’ve been a part of the team here. We’ve grown a lot as a company in that time, and it’s amazing that we’re able to maintain the same atmosphere in the office now as when there were only 30 of us. Being a flat organization, we still have the ability to work without a lot of unnecessary processes, and have the opportunity to work with a wide range of people – not just other engineers. Our day-to-day life hasn’t changed…we’re just a much bigger family now.

What’s your favorite thing you’ve worked on at Houzz?
I really enjoy working on new designs that continuously evolve our website. It feels like Houzz is our home, and we’re redecorating it! One of my recent favorite projects was creating a home for Houzz TV. It’s exciting that we’re providing Houzzers with an opportunity to experience Houzz in a new way, through video.

What’s the development process like at Houzz?
It’s very collaborative. Our team involves everyone from the very beginning of a project, and we’re all able to offer our ideas right from the initial iteration phase. Once we’re all happy with a solution we continue to A/B test it to make sure our community is just as pleased as we are.

When do you write your best code?
In the afternoon. I like to triage any necessary fixes that come through over email first thing in the morning, so I can focus on coding in the afternoon. Our team doesn’t hold a lot of meetings, so we’re able to concentrate on getting our work done.

How have you used Houzz at home?
My husband and I have taken on several renovation projects to make our home our own since we bought it four years ago. So far we’ve updated our living room, two bathrooms, and the backyard. We used Houzz to create ideabooks to gather ideas for all of these spaces, buy materials and collaborate with each other and the pros working on the projects. We’ve done this all slowly over the years. Rather than completely updating a home as soon as I move in, I prefer to live in the house for a while and see what it needs over time.

What’s the style of your home?
Since it’s an Eichler, the overall design of the home is mid-century modern, though I gravitate toward a modern minimalist style. I like things with clean lines, but not too much black and white – I like a splash of color. I think I’ve seen this style described as “happy modern.”   

What do you like to do when you’re not working?
My hobbies keep changing! My husband and I spend a lot of time traveling and hiking with our Shibu Inu, Maui. We are also almost always in the middle of a renovation or decorating project. I also spend a lot of time on Houzz, of course, testing the products I’m working on, but also enjoying the site. This definitely inspires more projects!