function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
LosintikfosLosintikfos 

WSDL2APEX

Hi Experts,

Quick advice! i have a WSDL2Apex class on my sandbox which i want to deploy to prod. My question is, do i need to write a test class for it before it can be successfully loaded to salesforce?



B
devNut!devNut!
If the test coverage for your class meets the minimum requirements you should have no problem.

In the Force.com IDE right click on the "classes" folder
select Force.com
select Run Tests

to see the test coverage of your classes.

http://wiki.apexdevnet.com/index.php/Force.com_IDE

LosintikfosLosintikfos
I did as instructed devNut! and got Failures and warning.

message: Average test coverage across apex classes and triggers is 0%, atleast 75% coverage is reguired.
149 lines notes tested, 0% covered.

Does it mean i need to write a test for the wsdl to apex class.




Message Edited by Losintikfos on 08-26-2008 07:00 AM
devNut!devNut!
Yes it means you have to write test coverage  
LosintikfosLosintikfos
Wow! sorry do you have sample test class for wsdl2apex class i can walthrough?


devNut!devNut!
Check out
http://www.salesforce.com/us/developer/docs/apexcode/index.htm

and search for "Testing and Code Coverage"
LosintikfosLosintikfos
Thanks for the link devNut!

I have a quick question! my appex classes after clicking on run test derives the message:

Code Coverage results:
0 lines not tested, 100% covered! withought any warnings or failures - yet i can't deploy it to production. Do you know why?



Message Edited by Losintikfos on 08-26-2008 07:32 AM
LosintikfosLosintikfos
Do anyone knw why!
devNut!devNut!
Are you running the tests by right clicking on the file or the "classes" folder ?

Right click on the "classes" folder and select Force.com -> Run Tests
LosintikfosLosintikfos
I am doing something like this:

Classes > Force.com > Run Test

This then generate the message:

Code Coverage Results
0 lines not tested, 100% covered.


But when i do deploy to server i dont have the code change appearing on salesforce.


Message Edited by Losintikfos on 08-26-2008 08:13 AM
LosintikfosLosintikfos
Do you know why this is happening<?
devNut!devNut!
After you select "Run Tests"

In the "Apex Code Text Runner" tab, do you see an expandable section called "Code Coverage Results" ?
LosintikfosLosintikfos
Yeah! this is the portion where the message generated  is output from eclipse.

i see something like this:

green check mark followed by the apex class name -- message 0 lines tested, 100% covered
LosintikfosLosintikfos
Do i need to do something else?
LosintikfosLosintikfos
I found the issue! the files were not saved so wasn't build for the sforce project (Thanks for your help). Now generating errors for test class.

Quick qestion!
Do i create a seperate apex class for the testing or a method withing the apex class i want to test?
devNut!devNut!
Glad you got it working.

I would create a seperate test class. As a best practice start the name of the class with "test"
LosintikfosLosintikfos
Hi,

I have the class below;


global class APiNorthstar {

        WebService static string addAccount(String AccA, String name){

        comSFNorthstarApi.NorthstarServiceHttpSoap11Endpoint stub
= new comSFNorthstarApi.NorthstarServiceHttpSoap11Endpoint();
                  
                   /*Invoke remote method via the service stub*/
                   String call = stub.Northstar(name, AccA); 
                  
                   /*Return response*/
                   return call;
        }
    }


I am writing a test class below to invoke it;

public class testAPiNorthstar {
          public static testMethod void testAPi(){
          string AccA = 'A';
          String name = 'B';
          APiNorthstar test = new APiNorthstar();
          string pipe = test.addAccount(AccA, name);
        System.debug(pipe);
      }
}

My problem is, if i try to save the test class i get error:

Error: Compile Error: Static methods cannot be invoked through an object instance: addAccount(String, String) at line 6 column 25

Do you know what i am doing wrong here?

Help please.:smileysad:


Message Edited by Losintikfos on 08-27-2008 04:44 AM
devNut!devNut!
Since your addAccount method is static you should access it like :

string pipe = APiNorthstar.addAccount(AccA, name);
LosintikfosLosintikfos
:smileyvery-happy: That was brilliant devNut! absolutly fantabulous.

Quick question! do you know whay i am getting 15% coverage?

I decided to change it to below, to cover the soap API invocation but still returns 15% - need your expert advice dev!

public class testAPiNorthstar {
          public static testMethod void testAPi(){
          string AccA = 'A';
          String name = 'B';
          string pipe = APiNorthstar.addAccount(AccA, name);
          System.debug(pipe);
      }
}



Message Edited by Losintikfos on 08-27-2008 05:42 AM
LosintikfosLosintikfos
Sorry devNut my perfect expert! it finally turned from 15% to 80% when i did a deploy from eclipse. Everything is working absolutly fantababulous now. Oi you the mann.


Cheers:smileyvery-happy:
devNut!devNut!
It is hard for me to tell but the Force.com IDE should tell you which lines in your class still need to be covered.

Use that as your guide when writing the test class.
sf11sf11

I rely on test coverage screen to review the lines of code covered under test method.

 

if you click on the coverage percentage (e.g. 65%) the popup shows your code and the lines which are not covered by the test method are highlighted in red.

 

Would love to see a feature like this in Force.com IDE.

Kirill_YunussovKirill_Yunussov

So did you ever create a test class for the wsdl2Apex class, or only for the APINorthstar class?  I currently am looking into creating a test class for a wsdl2apex class, but having trouble doing that.