Here is the CaseHandler Class  public class CaseHandler {     public static void onCaseInsertOrUpdate(List&lt;Case&gt; newCases, Map&lt;Id, Case&gt; oldMap){         List&lt;Id&gt; acctIds = new List&lt;Id&gt;();         Map&lt;Id, String&gt; acctIdChildNames = new Map&lt;Id, String&gt;();         for (Case record: newCases) {             if (record.Household__c != null &amp;&amp; (oldMap == null || record.Household__c != oldMap.get(record.Id).Household__c)) {                 acctIds.add(record.Household__c);             }         }          if (acctIds.isEmpty()) {             return;         }          List&lt;Child__c&gt; children = [SELECT Id, Household__c,Child_Name__c, Child_Age__c FROM Child__c WHERE Household__c IN :acctIds];          for (Child__c child: children) {             if (acctIdChildNames.containsKey(child.Household__c)) {                 String childName = acctIdChildNames.get(child.Household__c) + '\n' + child.Child_Name__c + '(' + child.Child_Age__c + ')';                 acctIdChildNames.put(child.Household__c, childName);             } else {                 acctIdChildNames.put(child.Household__c, child.Child_Name__c + '(' + child.Child_Age__c + ')');             }          }          // No need to write update because we are triggering this on before trigger         for (Case record: newCases) {             if (record.Household__c != null) {                 record.Children_Names__c = acctIdChildNames.get(record.Household__c);             }         }     } }   Here is the test class  @isTest public class CaseHandlerTest {     @isTest     static void caseInsertTest() {         Account a = new Account(Name='Test');              Child__c child = new Child__c(Child_Name__c='Child 1',Child_Age__c=10,Household__c=a.Household_ID__c);         Case c = new Case(Status='New',Household__c=a.Id);         Test.startTest();         insert a;         insert child;         insert c;         Test.stopTest();         System.debug('Child Name : '+child.Child_Name__c);         System.debug('Case Id : '+c.Id);         System.debug('Account Id : '+a.Name);         c = [SELECT Children_Names__c FROM Case WHERE Id =:c.Id];         System.debug('Children name and age: ' + c.Children_Names__c);         System.assertEquals('Child 1 (10)', c.Children_Names__c);     }     }   But I am getting 41% code coverage could you please help me out on this.
This is a canonical question and answer developed by the community to help address common questions. If you've been directed here, or your question has been closed as a duplicate, please look through the resources here and use them to shape more specific questions. To browse all canonical questions and answers, including more unit test resources, navigate to the  tag.  This canonical question is intended to address several classes of common questions by providing a quick summary and links to comprehensive resources:   How is code coverage obtained and calculated? How do I increase my coverage?  Why can't I cover these lines? Why isn't the body of my loop or conditional statement covered?
How can I check dependency list for a deb package Consider the following minimal example:  \documentclass{article}  \setlength{\parindent}{0mm}  \usepackage{paralist} \usepackage{tabto}  \begin{document}  \NumTabs{3} \begin{inparaenum} \item text \tab\item text \tab\item text \tab\item text \tab\item text \tab\item text    \end{inparaenum}  \end{document}   Which results in:    It does exactly what I want, but I was wondering whether it was possible to create an environment, say tabbedEnum so that we can eliminate the use of the \tab, in particular, that the first case doesn't need a tab but all others do. Something of the form:   \begin{tabbedEnum}[3] \item text \item text \item text \item text \item text \item text \end{tabbedEnum} How can I visualize the file system usage on Windows? DeleteDuplicates[] does not work as expected on floating point values Suggested Edits Dashboard doesn't agree with Suggested Edits view Why doesn't Spotlight show invisible files that I know exist? I am running Mac OS X 10.8 (Mountain Lion) and had to edit an invisible file as part of an Android project. While I eventually found it, Spotlight was of no help, since it could not find an invisible file when searching for the exact name (.classpath) and with the 'File Visibility' option set to 'Visible or Invisible'.  Why didn't Spotlight work in this instance? Is it possible to search for down voted questions? I have a hook_form_alter in a module, and it should be firing, but it appears it's not. I've cleared caches and rebuilt the registry. Is there someplace in the database or somewhere else where I can see if my hook is registed? FWIW here is my hook:  /**  * Implements hook_form_alter  */ function my_module_form_alter(&amp;$form, &amp;$form_state, $form_id) {   drupal_set_message($form_id); } Does Java have buffer overflows? I found a feature request at  but it doesn't seem easy to get a column view with Nautilus while with Mac OS X it's a default feature.  Have I missed something or is this not currently possible? Debian 8 apt-get update showing 404 Not Found I got the following output every time I run apt-get update on my Debian 8.   Is there a way to fix this?   Err http://ppa.launchpad.net jessie/main amd64 Packages                         404  Not Found Ign http://ppa.launchpad.net jessie/main Translation-en                 Err http://ppa.launchpad.net jessie/main amd64 Packages                   404  Not Found Ign http://ppa.launchpad.net jessie/main Translation-en                 Fetched 164 kB in 3s (47.0 kB/s)                                        W: Failed to fetch http://ppa.launchpad.net/certbot/certbot/ubuntu/dists/jessie/main/binary-amd64/Packages  404  Not Found  W: Failed to fetch http://ppa.launchpad.net/ondrej/php/ubuntu/dists/jessie/main/binary-amd64/Packages  404  Not Found  E: Some index files failed to download. They have been ignored, or old ones used instead.   And this is what I have in /etc/apt/sources.list  deb http://ftp.debian.org/debian/ jessie main deb-src http://ftp.debian.org/debian/ jessie main  deb http://security.debian.org/ jessie/updates main deb-src http://security.debian.org/ jessie/updates main  # jessie-updates, previously known as 'volatile' deb http://ftp.debian.org/debian/ jessie-updates main deb-src http://ftp.debian.org/debian/ jessie-updates main  deb http://ftp.debian.org/debian jessie-backports main   And this is the output of cat /etc/apt/sources.list.d/*  deb http://ppa.launchpad.net/certbot/certbot/ubuntu jessie main # deb-src http://ppa.launchpad.net/certbot/certbot/ubuntu jessie main deb http://ppa.launchpad.net/ondrej/php/ubuntu jessie main # deb-src http://ppa.launchpad.net/ondrej/php/ubuntu jessie main deb http://ppa.launchpad.net/ondrej/php/ubuntu jessie main # deb-src http://ppa.launchpad.net/ondrej/php/ubuntu jessie main deb https://packages.sury.org/php/ jessie main deb https://packages.sury.org/php/ jessie main Is the wave-particle duality a real duality? When I want to register an account with Gmail now, it says "Google will send a text message containing a verification code to your mobile phone."  I don't want to give Google my mobile phone number!!  How do I get around this? The description of the  says:     Your Intelligence score is 19 while you wear this headband. It has no   effect on you if your Intelligence is already 19 or higher.   The  spell description says that my Intelligence score becomes 1 on a failed save:     [...] On a failed save, the creature's Intelligence and Charisma   scores become 1. The creature can't cast spells, activate magic items,   understand language, or communicate in any intelligible way. [...]   If I am affected by Feeblemind and I am wearing the Headband of Intellect, would I have an Intelligence score of 19 or 1?   Also, what about the other effects like not being able to cast, activate magic items, understand languages or communicate in any way? Those seem Intelligence-related, but are mentioned additionally to the reduction.   If the Intelligence score becomes 19, are the other effects still active? If a function can only be defined implicitly does it have to be multivalued? Quantum entanglement: does it necessarily imply superluminal information transfer? Can't Remove Cortana from Windows 10 Using (or not) the word "to" in a sentence ending with "be able" Which of these is grammatically correct?   As educators, we are always looking for ways to reach all the learners in our classroom as effectively as we are able.   As educators, we are always looking for ways to reach all the learners in our classroom as effectively as we are able to. How are answers with the same vote score sorted? Do you say "I like apple" or "I like apples"? When stating a general fact/preference on countable nouns, singular or plural is more suitable and natural? Example 1 :  I like apple. or I like apples.  Example 2:  I like eating apple. or I like eating apples.