0

I've got stuck, some help would be much appreciated…</p>

I'm using xml like a mini database, I've got php creating an array of images from the xml file, all this works fine. I want to use some of those images as part of this nice jquery zoom thingy > http://www.elevateweb.co.uk/image-zoom/examples

Here's where I'm at:

document.write("<img id='zoom_01' src=" + "../../shop/e20_portal/" + imagelist_s_array[0] + "' data-zoom-image='../../shop/e20_portal/" + imagelist_l_array[0] + "'/>");

both these correctly spit out the right url, EG:'e20_s.jpg' but the above code doesn't work.

imagelist_s_array[0]
imagelist_l_array[0]

Ok so to start of Test cases are especially good and important for larger projects. As this is automated testing it saves developer sh*t loads of time ;).

@Test
public void test1(){
    Webpage n = new Webpage("www.facebook.com"); 
    asssertequals(n.getURL(), "www.facebook.com");
}

So first is first:

@Test 

this annotations is used so the compiler knows which methods are actual tests.

Webpage n = new Webpage("www.facebook.com"); 

In here you are simply declaring variable "n" to be url (facebook)

asssertequals(n.getURL(), "www.facebook.com");

This is where the magic happens. assertequals checks if the variable equals to what we expect. If they are equal in this case test passes. but if you had this

Webpage n = new Webpage("www.facebook.co.uk"); 
asssertequals(n.getURL(), "www.facebook.com");

Then the test will simply fail because expect www.facebook.com but we give co.uk

There are also plenty of other asserts you can use for testing enter image description here

Also for more info refer to this website: i have found it particularly well organized and written as well as easy to understand

http://www.tutorialspoint.com/junit/junit_overview.htm

4

1 回答 1

0

如果我在 document.write 中手动输入 url,它就可以工作。

如果我输入“../../shop/e20_portal/e20_l.jpg”,它就可以工作。如果我在浏览器中输入完整的内容,图像会显示,是的

在某处使用 '' 而不是 " 可能存在问题。

于 2014-05-12T17:45:13.407 回答