Win a copy of Microservices in Action this week in the Web Services forum!

Mark D Anthony

Ranch Hand
+ Follow
since Oct 03, 2016
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
1
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mark D Anthony

Hi,
I have some cucumber tests in my java project.

I have two seperate feature files.

Previously,  I had one runner class which executed the tests and generated a JSON report.

But now,  I have two runner classes,  but I want to run these runner classes one after the other,  and combine the results of them into one JSON file.

Does anyone know how I can do this?

Thanks a lot in advance
2 weeks ago
Hi,

I'm passing a string into an assertStatement, and want to assert that the value passed in as a String, is in fact an integer (after converting it to an integer).

How do I do this using a JUnit assert?
2 weeks ago


My Spring Boot application contains some API's which inserts some data into a series of databases.

I am writing automated tests that send input XML's to these API's & populate a H2 (in-memory) database.

All of my tests are running, and the majority of these are running except for some smalldatetime fields.

The value that we are expecting to be populating the H2 with is 01/01/1900 00:00:00:000, but the value that is being populated is 01/01/1970 00:00:00:000.

Strangely, when I send the same input XML to the Dev environment, the Dev DB is being populated with the correct value (1900)

Does anyone know what could be causing this issue?
3 weeks ago

Ron McLeod wrote:

Mark D Anthony wrote:This is working fine if the timestamp has 3 milliseconds, but if there are 0 milliseconds, 1, 2, etc. then the test fails.

What changes should I make so that this assert statement would cater for all of the possible timestamps?


Do you mean that the milliseconds portion of the timestamp could have between zero and three digits?:
    zero digits:   2018-11-16 13:55:23.
    one digits:   2018-11-16 13:55:23.4
    two digits:   2018-11-16 13:55:23.41
    three digits:   2018-11-16 13:55:23.415



Hi, thanks for responding.

Yep, that's what I meant.
Hi,

I am using JDBC to query an SQL Server DB in my acceptance tests.

In one of my tests, the query returns a timestamp in the ResultSet. The problem that I'm facing is that the timestamp will be different each time the test runs, so I can't use an AssertEquals to verify the timestamp is correct.

Instead, I'm using the below assert statement:



This is working fine if the timestamp has 3 milliseconds, but if there are 0 milliseconds, 1, 2, etc. then the test fails.

What changes should I make so that this assert statement would cater for all of the possible timestamps?

I simply need to make sure that a timestamp is being returned, rather than the actual value.


Thanks a lot for any help in advance!
I'm using a H2 database, so I'm populating the table myself. I've added very few records, maybe 5
1 month ago

Carey Brown wrote:If clientNo is a String then it should be enclosed in single quotes in your query. Still not sure if this is your issue though.



So I've tried to strip back the code & am using this now:



The tests are failing now, but not for the reason I want.

For the invalid ext_client_id, the error message I am getting back is:

Expected <[asdf]> but was <[95893]>



I don't have a link_id equal to 95893, but I do have a link_id equal to 95892. Not sure if this has something to do with it
1 month ago

Carey Brown wrote:

Mark D Anthony wrote:When I assign 99 to this.clientNo, the test passes.
But, when I replace "this.clientNo" with 99 (hardcode it), the test fails.


Now that is curious. What data type is clientNo? Could you repost all of the code so that we're in sync.



Here is my method:



I am passing the clientNo in from a cucumber examples table, and am assigning it in this method:

1 month ago

Mark D Anthony wrote:

Carey Brown wrote:As Tim mentioned, you are calling rs.next() twice. Here's another possible way to deal with it.



I've tried this snippet, but the test is still passing when I pass 99 in as clientNo, even though 99 isn't in the database



When I assign 99 to this.clientNo, the test passes.
But, when I replace "this.clientNo" with 99 (hardcode it), the test fails.
1 month ago

Carey Brown wrote:As Tim mentioned, you are calling rs.next() twice. Here's another possible way to deal with it.



I've tried this snippet, but the test is still passing when I pass 99 in as clientNo, even though 99 isn't in the database
1 month ago

Mark D Anthony wrote:

Tim Moores wrote:If there's exactly one result being returned then this code will misbehave. That's because rs.next() is called twice. Instead of while (...) { ... } you could use do { ... } while (...).



Hi, thanks Tim for your response. This test will always only return one record, yes.



Here is my latest code now:



But, when I get this I get the following error:

org.h2.jdbc.JdbcSQLException: No data is available [2000-197]


1 month ago

Tim Moores wrote:If there's exactly one result being returned then this code will misbehave. That's because rs.next() is called twice. Instead of while (...) { ... } you could use do { ... } while (...).



Hi, thanks Tim for your response. This test will always only return one record, yes.
1 month ago
The below java test is querying an SQL Server database. But, when I assign an invalid value to this.clientNo (i.e. an ID that does not exist in tclientlink) the test still passes.




The below sys.out's are not appearing in the console, so I think there's an exception that I'm not handling:

1 month ago
Hi,

The application I am using is Spring Tool Suite, which is basically the same as Eclipse. Yesterday, I was able to open the application fine.But today, when I try to open I get the following errors:

Java Virtual machine launcher error: could no tfind java.dll

, then when I click OK I get this error message:

Java Virtual machine launcher error: could not find java se runtime environment



I haven't changed any configuration, so I don't know what's causing this error.

I am using Windows 7 also.
2 months ago
Hi,

I am writing Cucumber tests for a gradle Spring Boot app. At the moment, I am using REST Assured to validate the response body I am getting back from my micro services.
The next step is to validate the actual database column values that have been created / updated during the tests.

I am writing to a H2 (in-memory) database in my tests currently, but don't know how to check the table values.

Someone mentioned using DbUnit, but I'm not sure if that's correct. Can someone please point me in the direction I should be going please?
2 months ago