我在寫一個Junit測試,其中預期的結果是一個XML字符串。代表預期字符串的最佳方式是什麼?現在我把它作爲一個stringBuilder,我做了以下。我想斷言實際和預期是相同的。什麼是最有效的方式來表示這個預期的字符串?另外我不希望任何人改變預期的字符串,所以它也應該是最終的。Junit測試的預期結果的Xml字符串表示
@Before
public void setUp() {
expected.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
expected.append("<n-relationship guid=\"IEEBFAD40BC5711DFAE41F5F92790F896\" control=\"add\">");
expected.append("<n-relbase>ID17A8B10BC5711DFAE41F5F92790F896</n-relbase><n-reltype>IPLS</n-reltype>");
expected.append("<ip.content><pub.no>1234567</pub.no>");
expected.append("<event.date>2010-09-10</event.date><event.code>02394802323</event.code>");
expected.append("<event.treatment>+</event.treatment><event.description>OPPOSITION DISMISSED</event.description>");
expected.append("</ip.content></n-relpayload></n-relationship");
}
+1規範化器 – 2010-11-02 17:26:20