سؤال

I am struggling with a concordion test case.

Concordions are primarily aimed at asserting that the value of the data is as expected. However, every once in a while, you need to show some data on the HTML that is just for viewing (perhaps so that the test case is more readable for someone who is just reading the HTML).

In my case I need to query a table and show some data. I DO NOT need to assert that the data is some particular value (that is happening somewhere further down the concordion).

<table concordion:verifyRows="#aCollection : getSomeBunchOfDataFromDB()">
        <tr>
            <th concordion:echo="#aCollection.firstRow">1st</th>
            <th concordion:echo="#aCollection.secondRow">2nd</th>
            <th concordion:echo="#aCollection.thirdRow">3rd</th>
            <th concordion:echo="#aCollection.fourthRow">4th</th>
        </tr>

Now this does the job alright. However, there is one gotcha. The code in its current format expects a bunch of rows. Hence it expects a bunch of trtds to show that data in. So, basically I have to provide a bunch of empty trs (precisely the number of rows that I am expecting from the database.

            <tr>
            <td />
            <td />
            <td />
            <td />
        </tr>
        <tr>
            <td />
            <td />
            <td />
            <td />
        </tr>

This works. But of course this is hacky. I have not been able to find some way to get the job done (i.e. showing a bunch of resultset in Concrodion HTMLs) without needing a long list of empty trtds.

If anyone have faced the problem and / or fixed something like this, please post back.

هل كانت مفيدة؟

المحلول 2

Thanks @mszalbach for your answer. I think you are right.

However, I was just looking for a quick fix, which does not look ugly. I don't mind it to be hacky really and I did not really care about creating the HTML in my java code when I was fine with the HTML that concordion provided (except for the red highlight). So I took the approach that took least effort (defintely hacky but it works) and that does not look too bad (it does not need a long list of empty TRTDs).

I hijacked the default css of concordion. :)

<style>
.surplus,.surplus * {
    background-color: white;
}
</style>

Stick that at the top of your HTML and you are good to go.

Not to take away any credit from @mszalbach. I think you approach is the "right" thing to do. Mine is just the "correct" thing to do when you hae a looming deadline and you just need the concordion to look alright unless some asserts are breaking.

نصائح أخرى

You could try the embeded extension for concordion.

So you would add

@Extensions(EmbedExtension.class)

To your class and can then use a method getSomeBunchOfDataFromDBFormatedAsHtml which returns a String with html code with your <td>s generated by a loop and show this table with:

<span ext:embed="getSomeBunchOfDataFromDBFormatedAsHtml()"/>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top