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
jhansisridhar_2011jhansisridhar_2011 

Help me to write test class for XMLStreamwriter.

Hi All, Help me to write a test class for below code,

public void storeProducts(){

XmlStreamWriter w = new XmlStreamWriter();

w.writeStartElement(null, 'Product', null);

w.writeStartElement(null, 'Id', null);

w.writeCharacters(p.Id);

w.writeEndElement();

...............

..................

............................

}

Test class: I have written test class as,

 

static TestMethod void storeProducts (){

XmlstreamWriter demo = new XmlstreamWriter();
          string result=demo.getXmlstring();
          string expected='<?xml version="1.0"?><?Products?>' + '<m:Product>' + '<00190000009rvgY>'; // is any other way to represent this line//
        System.assert(result == expected);

}

 

Failure: System.AssertException: Assertion Failed.


Thanks in Advance.

Navatar_DbSupNavatar_DbSup

Hi,

This is a duplicate post please make sure that you do not post any duplication questions on discussion board. So I request you to please remove it. For information regarding this post you can go to the following link:

 

http://boards.developerforce.com/t5/New-to-Cloud-Development/Help-me-to-write-test-class-for-XMLStreamwriter/m-p/424389#M4255

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.