You need to sign in to do that
Don't have an account?
soma
Running Tests and Synchronization in Eclipse
I recently installed Eclipse 3.3.1.1 for Java Developers and I installed the Force.com Apex plug-in, as well. I started a new Force.com project and added a new Apex Class, though I added this class under the default "unpackaged" category (so in the package explorer pane it appears under <project name>/src/unpackaged/classes/<class name>.cls). If I right click > Force.com > Run Tests, a dialog appears saying "Operation in progress..." (which closes immediately), and then the "Apex Code Test Runner" pane pops up, but no information appears within the pane indicating any sort of test was run. When I set the "Logging Level" to "Profiling (maximum verbosity)", I see several messages indicating there is no profiling information for SOQL, DML, and method invocations. It's as if the interface runs, but it executes no real analysis.
When I attempt to synchronize, save to the server, or apply the project to the server, the same thing occurs. An "Operating in progress..." dialog pops up, then nothing else occurs indicating anything has happened.
Here's the class I'm attempting to run tests on:
When I attempt to synchronize, save to the server, or apply the project to the server, the same thing occurs. An "Operating in progress..." dialog pops up, then nothing else occurs indicating anything has happened.
Here's the class I'm attempting to run tests on:
Code:
global class XmlEmailUtil { public static String AddXmlTagPair(String name, String value) { if (name == null) { return ''; } return ' <tag_pair>\n' + ' <name>' + name + '</name>\n' + ' <values>\n' + ' <value>' + value + '</value>\n' + ' </values>\n' + ' </tag_pair>\n'; } public static void SendXmlEmail(String id, String body, String toAddress) { Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); email.setToAddresses(new String[] { toAddress }); email.setSubject(id); email.setPlainTextBody(body); Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email }); } static testMethod void TestAddXmlTagPair() { AddXmlTagPair(null, null); AddXmlTagPair(null, 'value'); AddXmlTagPair('name', null); AddXmlTagPair('name', 'value'); } static testMethod void TestSendXmlEmail() { SendXmlEmail(null, null, null); SendXmlEmail(null, null, 'cgarrett@p4healthcare.com'); SendXmlEmail(null, 'body', null); SendXmlEmail(null, 'body', 'cgarrett@p4healthcare.com'); SendXmlEmail('id', null, null); SendXmlEmail('id', null, 'cgarrett@p4healthcare.com'); SendXmlEmail('id', 'body', null); SendXmlEmail('id', 'body', 'cgarrett@p4healthcare.com'); } }
system.debug('here');
this shoudl then show up in the debug log when you set the log level to debug, then you are sure your code is running.
can you run the test method from the "run test" button in the application ?
what do you see there?
I have also problems with Eclipse:
I become on the Apex Code Test Runner: Test coverage of selected Apex Class and Trigger is 0%...
I don't know why.
Another point: Eclipse has for all tags: "unknow tag"
Wen I use Execute Anonymous I have in Result:
Compile error at line 1 column 1
unexpected token: null
Do you have an Idea?
Thx
Magda
The only "Run Tests" button I see is in the "Apex Code Test Runner" pane and it say"Re-Run", but this has the same effect as attempting to run the code from the right-click menu.
I have also a new Problem:
But i'm using Eclipse in Online Modus....
Do you have an Idea?
Thx
Magda
As for my issue, I discovered the problem. I had been developing in the Salesforce sandbox without the use of Eclipse. Then, when I wanted to port the code from the sandbox to production, documentation suggested there were two options: the ANT tool or Eclipse. Documentation appeared to detail the use of the ANT tooin more words than Eclipse, but I found a number of questions relating to the ANT tool and a few recommendations against its use, so I went the Eclipse route. I created a new project in Eclipse, then added a new trigger and a new utility class, pasting code into those new additions from the code I developed already in the sandbox. For the project, I initially set it up with the URL of the production salesforce server thinking that was appropriate since that's where I wanted the project to live, but this is where the problem was: the URL I specified should have been the sandbox URL. Documentation, in a roundabout way, talks about deploying to production from a sandbox, but it doesn't say that it's required to first set a project up in Eclipse using a testing environment URL. Even more confusing is the fact that Eclipse allows you to set the initial URL for the project to the production server. Doing this, however, causes the strange non-processing issues I mentioned in my original post in this thread. As soon as I changed the URL to the testing environment (the sandbox), I was able to run tests and see code coverage. I was even able to synchronize and save my work to the testing environment.
Message Edited by soma on 02-19-2008 11:45 PM
could you please give me the different URLs?
I have already not the posssibility to do this test. Maybe I have to create a new Project...
What I don't understand, I'm able to synchronize and save my code the salesforce...
Message Edited by magda on 02-19-2008 11:52 PM
Salesforce URL: Sandbox URL or Test URL with salesforce....
https://test.salesforce.com/services/Soap/u/11.1
I chose the first one: https://test.salesforce.com/services/Soap/u/11.1 and then my problems went away. Saving my work and synchronizing all manipulated code in the sandbox, so this URL (https://test.salesforce.com/services/Soap/u/11.1) appears to refer to the sandbox.https://www.salesforce.com/services/Soap/u/11.1
https://prerelwww.soma.salesforce.com/services/Soap/u/11.1
Message Edited by soma on 02-19-2008 11:59 PM
I can use https://www.salesforce.com/services/Soap/u/11.1
But
If i try https://test.salesforce.com/services/Soap/u/11.1 i'm becoming a failure:
If i try to use : https://prerelwww.soma.salesforce.com/services/Soap/u/11.1
Do you have an Idea?
The first URL, the test URL, should work for you. I believe you're receiving the invalid username/password error because the format of your username is different when logging into the sandbox. I don't know if you've ever tried to log into your salesforce sandbox on the web, but when you do it takes your username and appends ".apex" to it [edit: it added '.apex' to my username because 'apex' was the name of my sandbox]. So if your username to login to your standard salesforce account is "magda@example.com", then your username to log into your sandbox would be "magda@example.com.apex". Try using this format for your username when using the test.salesforce.com URL.
If that STILL doesn't work, the only other issue I can imagine is that you're experiencing some sort of security token issue, but if you can log into the www.salesforce.com URL without an issue, then I don't tihnk it's a security token issue.
Message Edited by soma on 02-20-2008 01:42 AM
i refresh the security token, und add .apex but it is not running...
Allways the same problem :
Do you think I have to open a case by salesforce?
Oder do you have another Idea?
Thx
Magda
Regarding the security token, you said you refreshed it. Are you using it? That is, are you appending the security token to the end of your password? I'm sure you're already aware of how to use the security token, but just in case... You may not even need to if you've given your IP network access by adding it to the whitelist in salesforce. But if your IP isn't in that whitelist then you will need to append the security token to your password, of course.
How can I:
- connect to the sandbox from my browser?
I connect me to Salesforce and I can see my Application, but how can I know which kind of organisation it is?
- adding my IP in whitelist for salesforce?
About Security Token, yes i use the new one.
I have this problem in Eclipse:
Message Edited by magda on 02-20-2008 01:16 AM
Message Edited by magda on 02-20-2008 01:20 AM
1. Click 'New Sandbox'
2. Give it a name, optional description, you can leave just the 'Apex' radio button selected, then press 'Start Copy'.
When you press 'Start Copy', the objects in your production environment are copied to your sandbox environment so you can interact with them like normal. Depending on how many objects and applications you have, this copying process can take a while. Looking at the sandbox listing when the copying is done, in the "Action" column you should eventually see two links: Refresh (this will be inactive at first since you just created this sandbox) and Login. If you click on 'Login', you'll be taken to a login page that looks just like the login to your main salesforce account, but notice two things: the URL is different and your username is different (it has the name of your sandbox appended to it; note, I made an error in my earlier post when I said '.apex' would be appended to your username ['apex' is what I named my sandbox, so that is what was appended to my username]). So, at this login section, supply the same password you use for your main account. With that, you should be able to log into your sandbox. If you were able to do this, then go back to Eclipse and try connecting to the test.salesforce.com URL again.
As for adding your IP to the whitelist, I don't know what sort of permissions you have or in what versions of salesforce you can do this, but for me (I have both administrator access and my company is using Unlimited Edition) I go to Setup > Security Controls > Network Access. If I don't see my IP in the list there, I just add it. With this, I don't have to use a security token when logging in from my computer.
Message Edited by soma on 02-20-2008 01:22 AM
But I don't have the Sandbox in Data Management.
Do you think I have to have this ulimitted edition to be abble to debug my application?
And could you please explain me what is sandbox? I don't realy understand for what is that use....
Thx for your help
Message Edited by magda on 02-20-2008 01:25 AM
But what is sandbox?
Thx you i had seen this link.
I have a devloper Edition
Message Edited by magda on 02-20-2008 01:38 AM
Thank you for your very quick answer....
It is very nice.
I will open a case to understand what we have to do to be able to use a sandbox.
I have to create Test Methods.
Do you have en example for test methods in apex classes?
I find online test in s controls, and wenn I want to use this one in my class it is not running.
Do you know how i can do that?
And If you know could you please explain me how i have to write this one.
Thx
Magda
it is correct to create a function :
public static testMethod void test()
and insert all what have to be testing in the classes?
Thx
Magda
I've only ever run test code on triggers, so that mostly revolves around creating objects, filling their fields, inserting them, modifying the field values and updating the objects again, and repeating this process to cover all if/else conditionals.
I try to test my trigger, but I don't know how....
My Trigger:
My TEst Method:
But My Eclipse said I cover only 66%.
I thought that i have to insert this object to test the trigger on this object. But it seems to be wrrong...
Do you have another Idea?
Thx
Magda
You are, however, on the right track in assuming that inserting Object ("insert Object") will cause testing code coverage. Are you actually creating this Object in your testMethod before you pass it to Function() and before you insert it? The way your example code is written, you're using 'Object' like an actual object, but you're not instantiating it or setting any of its properties. I think you may be inserting a null value. If you insert a null value, then when your trigger fires, trigger.new will be assigned to your Object__c[] Object array, but then making a call to Class.Function(Object[0]) would cause a null exception. Though, in reality, if you're trying to insert a null value, I'm not even sure your trigger will fire, but it's certainly possible.
I initialiezed my Object... But it is not running... Now there is 0% code coverage...
I don't understand why...
I had values for all field that i need in the FunctionObject
And my trigger bevore and after insert are not covered.
I don't understand why, because I'm duing an insert...
In my code, CreateFoo() is like your FunctionObject() function, creating an object, setting its values, and returning it. Of course, in this function you may apply other logic to create the values, but ultimately it's the same thing. In the code you showed me, it appeared you weren't instantiating your object, rather you were just trying to set field values without allocating a new object first. Anyway, hope this helps.
Now: Code coverage total %23
And I'm doing the same like you...
I don't understand
thx very much for your help.
Now it is running.
I had forgotten a field and it was a requiered field in the function....
Now I have 100 % Covered
Thx you :)
Magda
Take care.
I have a new Problem today.....
I have create a beta package, and I want to install it with another user. I become this failure:
Unable to install this package for the following reasons:
Do you have an idea?
Thx
Magda