This doesn't really seem like a jQuery question. However, regardless of whether you're creating this ID string in PHP or javascript, you can simply concatenate "test" with (for example) $row['id'] in PHP or row.id in JS. In PHP, the concat operator is a full stop "." and in Javascript it's a + sign.
Edit: a simple example to illustrate looping through for an append. Here I'm assuming you want the ID of each LI to be a value equal to test1 where 1 is the ID number such that id #2 looks like: test2.
var appendString = "";
var dataArray = new Array();
dataArray[0] = 1;
dataArray[1] = 2;
dataArray[2] = 3;
dataArray[3] = 4;
$.each(dataArray, function(i, val) {
appendString += '<li id="test' + val + '">ID ' + val + '</li>';
});
$('#mylist').append(appendString);
This can be viewed in action here: http://jsfiddle.net/VFFUj/2/
It's important to note that appending a full string like this in jQuery is actually faster than appending each LI on its own, so it's always best, if at all possible, to create your html string before you append it to the document.