Hi Ishara,

First of all, the method you wish to test should be public, if it isn't
public, you need to test the public one(s) calling it.

You will need do the following to have the test class and methods created.

   - Right click inside the source code for the class that has the method
   you wish to test and select 'Generate Test cases'

If you get a pop up error message saying 'error while generating test
cases', you will need to do the following;

   - Right click on the project in the eclipse project/package explorer
   view and select 'Properties'
   - In the left pane, click on 'Generate Test cases'
   - Then map a test source folder to the folder containing the class with
   the method you wish to test, this tells the plugin the source folder where
   you wish your test classes to be created

Wyclif

On Wed, Mar 21, 2012 at 1:24 AM, ishara premadasa <[email protected]>wrote:

> Hi devs,
>
> I am working on the introductory ticket 
> TRUNK-248<https://tickets.openmrs.org/browse/TRUNK-248>which needs adding 
> @should notations according to code comments. I was
> trying this with few classes, there are some things i need to clarify.
>
> As an example i came across this
> org.openmrs.api.db.hibernate.PatientSearchCriteria class which has
> following method.
>
>      /**
>      * Utility method to add identifier expression to an existing criteria
>      *
>      * @param criteria
>      * @param identifier
>      * @param identifierTypes
>      * @param matchIdentifierExactly
>      */
>     private void addIdentifierCriterias(Criteria criteria, String
> identifier, List<PatientIdentifierType>
>     identifierTypes,
>             boolean matchIdentifierExactly) {
>             *// TODO add junit test for searching on voided identifiers*
>
> According to the 
> guide<https://wiki.openmrs.org/display/docs/Unit+Testing+With+at-should+Annotation>provided
>  in the ticket, this should be annotated as,
>
>      /**
>      * Utility method to add identifier expression to an existing criteria
>      *
>      * @param criteria
>      * @param identifier
>      * @param identifierTypes
>      * @param matchIdentifierExactly
>      * *@should fail given null identifier*
>      */
>
> In addition to that it says there must be a method in the test class named
> *addIdentifierCriterias_shouldFailGivenNullIdentifier()*  which address
> this check. However there is no PatientSearchCriteriaTest class in the
> project. Do i need to create test classes and methods along with the fix
> for the error ? or is it only needed to change the code comment and add the
> annotation without considering modifying the test class method?
>
> Thank you very much!
> Ishara
>
> --
> *Best Regards.*
>
> *Ishara Premadasa,*
> Final Year Undergraduate,
> Dept. of Computer Science & Engineering,
> University of Moratuwa
> Sri Lanka.
> http://isharapremadasa.blogspot.com
>
>
>
>  ------------------------------
> Click here to 
> unsubscribe<[email protected]?body=SIGNOFF%20openmrs-devel-l>from 
> OpenMRS Developers' mailing list

_________________________________________

To unsubscribe from OpenMRS Developers' mailing list, send an e-mail to 
[email protected] with "SIGNOFF openmrs-devel-l" in the  body (not 
the subject) of your e-mail.

[mailto:[email protected]?body=SIGNOFF%20openmrs-devel-l]

Reply via email to