From: Jim S. <ji...@ji...> - 2010-05-20 16:38:27
|
It's giving you 100% statement coverage but not 100% branch coverage. It is behaving correctly. The reason you don't have 100% branch coverage is that you are testing the boolean condition again instead of just using else. So you have no way to make it take the second branch in the else if, because that second condition was already covered by the first conditional. In other words: if (cond(some boolean)) { <<< you can get this to evaluate true or false, but if true it will not get to the else if [...] else if (!cond(some boolean)) { <<< you can get this to evaluate true when first conditional is false, but not the other way around [...] } So when it gets to the else if, the only value cond can ever return is false, so the only way the second conditional can ever evaluate is true. It can never evaluate to false, so you can only take half the branches on the second conditional. ----- Original Message ----- From: "Anton Trapp" <tm...@al...> To: <cob...@li...> Sent: Thursday, May 20, 2010 6:59 AM Subject: Re: [Cobertura-devel] branch coverage of two function calls??? Hi! Thank you for your fast answer! As I said, I do run tests with true/false and the if statement is not even mentioned in the branches: Overview: code: So yes/No is working, but line 88 has line coverage but no branch coverage. I am understanding my question, but I don't understand what cobertura needs to branch in line 88 where there is not even a control structure... Regards, Anton Am 20.05.2010 um 15:39 schrieb Alejandro Pérez García: > Hi > > I'm sorry, but I thikn that I don't understand your question. > > If you want to cover the "else" sentence (the sentence you marked with > "THIS LINE") you only have to do "false" the yesNo expresion. > > I don't understand where is the problem. > > Regards > > > > > 2010/5/20 Anton Trapp <tm...@al...> > Hi! > > How can I cover the 4 branches of: > > if (yesNo) { > verifyTrue(selenium.isTextPresent("secure page")); > } else { > verifyFalse(selenium.isTextPresent("secure page")); <-- THIS LINE??? > } > > Code coverage is 100%, this test is called multiple times (yes I do > perform a code coverage of the tests, please do NOT ask why...) with yesNo > both true and false. So how can I test the 4 branches in the function > calls that I don't even see and why are there no function calls in the > second line which is almost identical. > > I always thought that branches are only for control structures like if, > ...? > > Anybody can help me? > > Thank you very much in advance! > > Regards, > Anton > > ------------------------------------------------------------------------------ > > > _______________________________________________ > Cobertura-devel mailing list > Cob...@li... > https://lists.sourceforge.net/lists/listinfo/cobertura-devel > > > > > -- > Alejandro Pérez García > Socio fundador de Autentia y www.adictosaltrabajo.com > (Formación, Consultoría, Desarrollo de sistemas transaccionales) > mailto:ale...@au... > Tel.: 655 99 11 75 > > Autentia Real Business Solutions S.L. > "Soporte a Desarrollo" > http://www.autentia.com > > > > Este mensaje, y en su caso cualquier fichero anexo al mismo, puede > contener información confidencial y/o privilegiada, siendo para uso > exclusivo del destinatario. Si Vd. no es el destinatario o lo ha recibido > por error, por favor, informe inmediatamente al emisor y destrúyalo. Está > estrictamente prohibido por la legislación vigente realizar sin > autorización cualquier copia, revelación o distribución del contenido de > este mensaje sin la autorización expresa del remitente. Las opiniones > expresadas en este correo son las de su autor y no son, necesariamente, > compartidas por Autentia Real Business Solutions S.L. > > This e-mail, and in the case of any file annexed to it, may contain > confidential and/or privileged information, and it is exclusively for the > use of the addresses of the message. If you are not the intended recipient > (or have received this e-mail in error), please notify the sender > immediately and destroy this e-mail. Any unauthorised copying, disclosure > or distribution of the material in this e-mail is strictly forbidden by > current legislation. The points of view expressed in this e-mail are > solely those of the author and may not necessarily be from, or supported > by, Autentia Real Business Solutions S.L. > -------------------------------------------------------------------------------- Hi! Thank you for your fast answer! As I said, I do run tests with true/false and the if statement is not even mentioned in the branches: Overview: code: So yes/No is working, but line 88 has line coverage but no branch coverage. I am understanding my question, but I don't understand what cobertura needs to branch in line 88 where there is not even a control structure... Regards, Anton Am 20.05.2010 um 15:39 schrieb Alejandro Pérez García: Hi I'm sorry, but I thikn that I don't understand your question. If you want to cover the "else" sentence (the sentence you marked with "THIS LINE") you only have to do "false" the yesNo expresion. I don't understand where is the problem. Regards 2010/5/20 Anton Trapp <tm...@al...> Hi! How can I cover the 4 branches of: if (yesNo) { verifyTrue(selenium.isTextPresent("secure page")); } else { verifyFalse(selenium.isTextPresent("secure page")); <-- THIS LINE??? } Code coverage is 100%, this test is called multiple times (yes I do perform a code coverage of the tests, please do NOT ask why...) with yesNo both true and false. So how can I test the 4 branches in the function calls that I don't even see and why are there no function calls in the second line which is almost identical. I always thought that branches are only for control structures like if, ...? Anybody can help me? Thank you very much in advance! Regards, Anton ------------------------------------------------------------------------------ _______________________________________________ Cobertura-devel mailing list Cob...@li... https://lists.sourceforge.net/lists/listinfo/cobertura-devel -- Alejandro Pérez García Socio fundador de Autentia y www.adictosaltrabajo.com (Formación, Consultoría, Desarrollo de sistemas transaccionales) mailto:ale...@au... Tel.: 655 99 11 75 Autentia Real Business Solutions S.L. "Soporte a Desarrollo" http://www.autentia.com Este mensaje, y en su caso cualquier fichero anexo al mismo, puede contener información confidencial y/o privilegiada, siendo para uso exclusivo del destinatario. Si Vd. no es el destinatario o lo ha recibido por error, por favor, informe inmediatamente al emisor y destrúyalo. Está estrictamente prohibido por la legislación vigente realizar sin autorización cualquier copia, revelación o distribución del contenido de este mensaje sin la autorización expresa del remitente. Las opiniones expresadas en este correo son las de su autor y no son, necesariamente, compartidas por Autentia Real Business Solutions S.L. This e-mail, and in the case of any file annexed to it, may contain confidential and/or privileged information, and it is exclusively for the use of the addresses of the message. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden by current legislation. The points of view expressed in this e-mail are solely those of the author and may not necessarily be from, or supported by, Autentia Real Business Solutions S.L. -------------------------------------------------------------------------------- > ------------------------------------------------------------------------------ > > |