I have a very simple controller extension and I'm trying to write a test Class, but I am only able to get 12% coverage. I'm not sure how to cover the rest of thelines below. Right now only my constructor is being covered: Controller Extension public class AcctAddresses {           public List&lt;Account_Addresses__c&gt; addresses{get;set;}      public string DelAddrId { get; set;}      public Account accounts {get;set;}       public Account acct {get;set;}        //Constructor       public AcctAddresses(ApexPages.StandardController controller) {           acct = (account)controller.getRecord();                accounts = [SELECT Id                     FROM account                     WHERE id=: acct.id LIMIT 1];           addresses = [SELECT Id, Primary__c, Street__c, City__c, State__c, Zip_Postal_Code__c, Country__c, Account__c                     FROM Account_Addresses__c                     WHERE Account__r.Id = :accounts.id ORDER BY Primary__c, State__c];       }     //This method is to delete the contact record while clicking the Del link       public pageReference deleteAddress(){          Account_addresses__c ToBeDeleted = [SELECT Id FROM Account_addresses__c WHERE id = : DelAddrId LIMIT 1];           delete ToBeDeleted;           String baseUrl = URL.getSalesforceBaseUrl().toExternalForm();           PageReference redirectPage = new PageReference(baseUrl+'/'+acct.id);           return redirectPage;        }     }  Test Class @isTest  private class AcctAddressesControllerTest {      static testMethod void testMethod1()      {         Test.StartTest();          Account testAccount = new Account();             testAccount.Name = 'Test JN Account';             testAccount.AccountSource = 'Networking';         insert testAccount;                  Account_Addresses__c testAcctAddr = new Account_Addresses__c();             testAcctAddr.Account__c = testAccount.Id;             testAcctAddr.Street__c = '1010 Test Ave';             testAcctAddr.City__c = 'New York';             testAcctAddr.State__c = 'NY';             testAcctAddr.Zip_Postal_Code__c = '11212';             testAcctAddr.Country__c = 'USA';             testAcctAddr.Primary__c = TRUE;             testAcctAddr.Current__c = TRUE;         insert testAcctAddr;          ApexPages.StandardController AcctAdd = new ApexPages.standardController(testAcctAddr);         AcctAddresses AcctAdd1 = new AcctAddresses(AcctAdd);         Test.setCurrentPageReference(new PageReference('Page.Acct_Addresses'));         Test.StopTest();     } }
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?
init.m in Autoload directory is not read by parallel kernels in M11.2 Disable Debug Log Programmatically I'm trying to disable WP_DEBUG_LOG if and only if debug.log exists. I'd like to hook into wp_footer and test if the file exists and if so disable my debug log. All I've found though is that WP_DEBUG_LOG is a constant and can only be changed from the wp-config.php file which is too early for my case. Is there a way to change it from a constant on install and keep it working as normal?   My only other thought is to create an option on install in the options table and just check it every time wp-config loaded to see if the value has changed but I was wanting to avoid that.   Granted I could check if the file exists before I define WP_DEBUG_LOG but somebody would have to view a page twice before debug log actually exists and is detected by the file_exists() (since it's run very early) which is not optimal.  Does anybody know of a workaround to programmatically turn off WP_DEBUG_LOG? I have created some search entries in Google Chrome using 'Edit search engines'.  How can I share some of these entries with my colleagues? Keep sharp edges when using subdivision surface How can I use the subdivision surface modifier to create more high poly meshes without ruining sharp edges? For example this mesh  The sphere should be subdivided but the rim of the cylinder should stay the same because it is a sharp edge. This is the result of the subdevision  How can I get sharp edges to not be affected by the sub surf mod? How to get back Windows 10 [UEFI] after Legacy installation of Fedora 24? My linear algebra professor proved that      Diagonalizable matrices with complex values are dense in set of $n \times n$ complex matrices.   He defined a metric (I believe) that was somehow related to the usual metric on $\mathbb{R}^{n^2}$.  Then somehow proved that diagonalizable matrices were dense because for any matrix $A$ if $\det(A - \lambda I) = 0$ on an open subset, then $\det(A - \lambda I)$ was the zero polynomial.  I Googled around a bit and found some stuff talking about the Zariski topology, and I am not sure this is what I want. Most of what I have found on this topology is much more general than what he was doing.  Does anyone know any resources that would explain how to go about proving this statement?  Edit: I found out how to prove this the way my professor did.  We define the norm of a matrix by $$ |A| = \max\{|Ax| : |x| = 1 \}.$$ Now we have a distance $d(A, B) &lt; \epsilon$. You can prove that if $(A - B)_{ij} &lt; \epsilon/n$, then $|A - B| &lt; \epsilon$.  Let $p(x)$ be the characteristic polynomial of $A$, an $n \times n$ matrix.  $$p(x) = \prod_1^n (x - x_i) = x^n + (-1)\sigma_1 x^{n - 1} + \cdots + (-1)^n\sigma_n$$ where $\sigma_1, \ldots, \sigma_n$ are the elementary symmetric polynomials of $x_1, \ldots, x_n$ which are the eigenvalues.  The discriminant of the characteristic polynomial is a symmetric polynomial, therefore it can be written in terms of the elementary symmetric polynomials, which in turn can be written in terms of the entries of the matrix.  But since the discriminant is a polynomial, it only has finitely many roots. Therefore for $\epsilon &gt; 0$, by changing the entries of the matrix less than $\epsilon / n$ we can find a new matrix $B$ such that $|B - A| &lt; \epsilon$ and the discriminant is not zero.   The discriminant being not zero means $B$ has distinct eigenvalues, thus has a basis of eigenvectors. Therefore, it is diagonalizable.  Thus the set of diagonalizable matrices is dense in the set of matrices with respect to that metric. I have read that a holomorphic function in an open disc has a primitive in that disc. Does this mean that for any holomorphic function $f$ in any open set $U,$ that $f$ has a primitive? I say this because I can take a large enough open disc to cover the open set $U$ and find its primitive there. Is this a correct way of thinking? Is it now considered acceptable to follow a proper noun ... or any noun ... with a pronoun? E.g.      The President he issued a new executive order. Are there any rules in baseball which prohibit teams from "borrowing" players via trade? Every season near the trade deadline, we see teams that are out of it trading expensive players and/or free agents-to-be, typically for younger players or prospects.  For example, Matt Garza, set to become a free agent after the season, was traded to the Rangers for a few prospects.  It made sense for the Cubs to trade Garza, because he wasn't under contract any further than this season, and thus doesn't have much value to them.  Compare Garza to someone like Mike Trout, who is likely the most valuable property in baseball, given his skill and inexpensive cost over the next several years.  There's no way the Angels would trade him, because he'll be the cost-controlled centerpiece of the team for years to come.  However, with the Angels out of it this year, what if they wanted to trade Trout to a contender (say the Pirates), but only for the remainder of this season?  That is, they'd get several top prospects now, and would have an agreement with the Pirates that they'd trade him back in the offseason (for something pretty worthless, say for a journeyman minor leaguer).  The Pirates get Trout for the stretch run and are happy to give up a few prospects.  Trout doesn't have much value to the Angels this year, but he has a ton of value for next year.  So they get a few prospects for him, in exchange for the part of his career which has very little value to them.  So in effect, the Pirates are renting or borrowing him for the remainder of 2013.  Why don't trades like this happen?  Are there any rules prohibiting trades like this? Show that if $ \ A \cup B = A$ and $ \ A\cap B = A$ then $ \ A = B$ Question:  Show that if $ \ A \cup B = A$ and $ \ A\cap  B = A$ then $ \ A = B$  My attempt:  Proof by contradiction:  Assume $ \ A \cup B = A$ and $ \ A\cap  B = A$ and $ \ A \neq B$   Case 1: $ \exists \ x \in A, x\notin B$  If $ x \in A \implies x\in A \cap B \implies x \in A \ and \  x\in B  \implies x\in B$, a contradiction.   Case 2: $ \exists \ x \in B, x\notin A$  If $ \ x \in B \implies x\in A \cup B \implies x\in A$, since $ \ A \cup B = A$. Contradiction.   Is this approach correct? Could someone please show me how to do a direct proof? Question about how to interpret arbitrary elements I have a question about how to interpret arbitrary elements. When we say:  &quot;let $x$ be an arbitrary integer&quot;  &quot;let $x$ be any integer&quot;  &quot;let $x$ be an integer&quot;   at the beginning of proofs, are we saying:  &quot;let the symbol $x$ represent one of the integers, although it is not clear which specific integer the symbol $x$ represents&quot;.  If not, please let me know how I should think about the above statements. Thank you for your time.  Edit: I had a follow up question to the one I asked earlier. What do mathematicians mean by “arbitrary element” or “any element”. I can understand when mathematicians say “let $x$ be $4$” as this means “the symbol $x$ represents $4$”. Could someone please elaborate on why the specific terms “arbitrary” and “any” are used? Electric fields and potential E = electric field V = electrostatic potential r = distance ' = derivative   E = - (V)'   therefore if E increases V decreases Also if r increases E decreases                                                      because  E=kq/r^2 From 1 &amp; 2, if r increases then V increases But V=kq/r, so if r increases V decreases   Why does the 3rd point contradict with the 4th ? What does <<-EOC means? I'd like to know what the minus (-) and the EOC in the command below means. I know some languages like Perl allows you to chose any combination of character (not bound to EOF) but is that the case here? And the minus is a complete mystery for me. Thanks in advance!  ftp -v -n $SERVER  &gt;&gt; $LOG_FILE &lt;&lt;-EOC             user $USERNAME $PWD             binary             cd $DIR1             mkdir $dir_lock             get $FILE             bye EOC Construction of $\mathbb{CP}^2$ from $S^2\times S^2$ Show that $\mathbb{CP}^2$ is homeomorphic to the orbit space of $(S^2\times S^2)/\mathbb{Z}_2$. The action is given by $(x,y) \mapsto (y,x)$. My attempt: I can see that $S^2\times S^2$ is a subset of $S^5$. I am unsuccessfully trying to restrict the action of $S^1$ on $S^5$ to $S^2\times S^2$ to get the required map. Query a region within a larger region with GeoDjango REST API I have a working Django REST API which can query all the counties in a country. //My model class kenya_counties(models.Model):   objectid = models.BigIntegerField()   id_field = models.BigIntegerField()   county_nam = models.CharField(max_length=80)   const_code = models.BigIntegerField()   constituen = models.CharField(max_length=80)   county_cod = models.BigIntegerField()   shape_leng = models.FloatField()   shape_area = models.FloatField()   geom = models.MultiPolygonField(srid=4326)    def __str__(self):       return self.county_nam  //My Serializer class CountiesSerializer(serializers.ModelSerializer):   class Meta:      model = kenya_counties      fields = ('objectid', 'id_field', 'county_nam', 'const_code', 'constituen', 'county_nam', 'county_cod', 'shape_leng', 'shape_area')  //My view @api_view(['GET', 'POST']) def counties(request):    if request.method == 'GET':        data = kenya_counties.objects.all()         serializer = CountiesSerializer(data, context={'request': request}, many=True)         return Response(serializer.data)     elif request.method == 'POST':        serializer = CountiesSerializer(data=request.data)        if serializer.is_valid():            serializer.save()            return Response(status=status.HTTP_201_CREATED)                 return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)  //My url     re_path(r'^api/gis/counties/$', views.counties),  I get . How can I query just one county and display it on a react-leaflet map as shown below? &lt;MapContainer center={position} zoom={13} scrollWheelZoom={false}&gt;     &lt;TileLayer       attribution='&amp;copy; &lt;a href=&quot;http://osm.org/copyright&quot;&gt;OpenStreetMap&lt;/a&gt; contributors'       url=&quot;https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png&quot;     /&gt; &lt;/MapContainer&gt; If a product of relatively prime integers is an $n$th power, then each is an $n$th power How to calculate the division and remainder of a big number manually Let $x = 2017^{2017}$. How can I manually determine:   The remainder of the division of $x$ by $31$ The least significant digit of $x$ Is it possible to follow a user automatically? reformat date to have month in words Currently my text file looks like this..  David   Webb    Box 34 Rural Route 2    Nixa    MO  65714   (417)555-1478   555-66-7788 09-13-1970 Martha  Kent    1122 North Hwy 5    Smallville  KS  66789   (785)555-2322   343-55-8845 04-17-1965 Edward  Nygma   443 W. Broadway Gotham City NJ  12458   (212)743-3537   785-48-5524 08-08-1987 O'Reilly    Baba    123 Torch Ln    Joplin  MO  64801   (417)222-1234   456-65-3211 12-13-1999 Martin Bob  44 Boss Rd  Joplin  MO  64801   (417)888-4565   456-98-1111 01-01-2007   the dates are in the 9th field and I want to display them as January 7, 2017 instead of 01-07-2017 for example.  How should I do that? If using options please explain what they do briefly. Doing this in bash. Needing to put it in a script and output to a new file to preserve original. Running two independent instances of Chrome I use Chrome as my main browser.  I also spend a lot of time on a particular webapp that my company uses.  I'd like to keep those two things separate.  I can run the webapp in a separate window - but I'd like to go further than that.  I'd like to have it be identified by a different task in the Win 7 taskbar; ideally a different icon; and ideally a different title in Process Monitor.  How can I run a second, independent instance of Chrome, with a different title and icon, that won't merge with my main Chrome browser.