• ux5
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
On the getting started with APEX, I cannot complete the challange and I am receiving the following error:
 
Challenge not yet complete... here's what's wrong: 
Executing the 'generateStringArray' method failed. Either the method does not exist, is not static, or does not return the proper number of strings.

But in the Debug Execute Anonymous Window, I can successfully run the code.  Here is the code used in the Anonymous window.

List<String> rtnStr = StringArrayTest.generateStringArray(4);
System.debug(rtnStr);
System.debug('rtnstr.size='+rtnstr.size());
As prevously said, if I do a Check Challange from the trailhead module I recieve the error.  In looking at the log there are two suspicious lines.
18:53:07:031 EXCEPTION_THROWN [1]|System.AssertException: Assertion Failed: Expected: Test 1, Actual: Test 0
18:53:07:031 FATAL_ERROR System.AssertException: Assertion Failed: Expected: Test 1, Actual: Test 0  
Can anyone help with this.  Adding a test case did not remedy the problem but I may have done something wrong there.  

And here is my code:
public class StringArrayTest {

    public static String[] generateStringArray(Integer count){
        List<String> mylist = new List<String>();
        for (Integer i=1; i<=count; i++) {
            String myStr = 'Test '  + i;
            System.Debug('Created '+ myStr);
            mylist.add(myStr);
        }
        System.debug('Completed!');
        return mylist;
    }

}

Question is:  Should I have to have a test case to complete this challange or have I got something else wrong?

TIA for your help
ux5
  • July 30, 2015
  • Like
  • 0