KeywordLogger doesn't seem to work anymore since version 5.9.0

… at least not in the same way as before.

**## Operating System: **Windows 7 / Windows 10

**## Katalon Studio Version: **5.9.0

**## Katalon Studio logs: **Can I hand it in later, if really needed.

## Environment (for Web testing)

  • Chrome v70.0.3538.110 (64 bit)

## Steps to reproduce

Create a new Test Case with following code:

import com.kms.katalon.core.logging.KeywordLogger as KeywordLogger
KeywordLogger log = new KeywordLogger()

**## Expected Behavior
**
The test case should be passed, as was the case up to version 5.8.3.
**
## Actual Behavior

**Console says something similar like this (non-printable characters manually edited):

2018-11-28 12:37:00.436 c.k.katalon.core.main.TestCaseExecutor - X log = new com.kms.katalon.core.logging.KeywordLogger() FAILED.

Reason:

java.lang.IllegalArgumentException: name argument cannot be null
[…]

2 Likes

I have exactly the same issue. It worked in 5.8.6.

KeywordLogger is now expecting Parameter (String testcasename). Try
KeywordLogger log = new KeywordLogger(’’)

3 Likes

Thanks, Jan, for that info. But apart from the fact that I wonder what this parameter is used/evaluated for, there is another problem with the logger:

It doesn’t log anything anymore!

Try this:

import com.kms.katalon.core.logging.KeywordLogger as KeywordLogger
KeywordLogger log = new KeywordLogger('')
def String secretVar = 'very secret!' 
log.logInfo("My secret is: ${secretVar}")

Up to version 5.8.3 the particular log result appeared like this:

TEST STEP: Statement - log = new com.kms.katalon.core.logging.KeywordLogger()

Start / End / Elapsed:2018-11-28 14:54:23.676 / 2018-11-28 14:54:23.677 / 00:00:00.001

TEST STEP: Statement - secretVar = “very secret!”

Start / End / Elapsed:2018-11-28 14:54:23.677 / 2018-11-28 14:54:23.678 / 00:00:00.001

TEST STEP: Statement - log.logInfo(My secret is: $secretVar)

Start / End / Elapsed:2018-11-28 14:54:23.678 / 2018-11-28 14:54:23.691 / 00:00:00.013
14:54:23.691INFOMy secret is: very secret!

Whereas it looks that way now:

TEST STEP: log = new com.kms.katalon.core.logging.KeywordLogger()

Start / End / Elapsed:2018-11-28 14:56:37.282 / 2018-11-28 14:56:37.285 / 00:00:00.003

TEST STEP: secretVar = “very secret!”

Start / End / Elapsed:2018-11-28 14:56:37.285 / 2018-11-28 14:56:37.287 / 00:00:00.002

TEST STEP: log.logInfo(My secret is: $secretVar)

Start / End / Elapsed:2018-11-28 14:56:37.288 / 2018-11-28 14:56:37.303 / 00:00:00.015

Note the missing last line, which should contain the actual parsed log entry!

2 Likes

Same issue with upgrade from 5.8.6 to 5.9

I’m currently trying to update all my tests to get them working as we used this everywhere.

Is there a way to pull the expected String testcasename from within the test itself? We have been creating lots and lots and lots of small little tests that are chained together, so every one has been instantiating a new KeywordLogger

It actually is even worse, since i execute these through docker and I use the 5.8.6 image from the Katalon Repository, it just fails because the keyword constructor can’t support

KeywordLogger log = new KeywordLogger('')
 (Stack trace: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: com.kms.katalon.core.logging.KeywordLogger(java.lang.String)

So this new version prevents us from running our tests which have been running for months as part of our CI integration. Or will force us to have bad source code control practices of either maintaining a 5.9.0 branch or keep swapping if we’re going between the UI and release test code.

Hi all,
Katalon team will fix the issue soon.

1 Like

Greg Roy said:

I’m currently trying to update all my tests to get them working as we used this everywhere.

Is there a way to pull the expected String testcasename from within the test itself?

As far as I know, not without Test Listener and globle variable. How this works you can find here: Can we get testcase name from code? - Archive - Katalon Community

Thanks Brian!

With the new version of today (5.9.1) it is unfortunately not fixed yet, I just checked.

@Drunda Nibel,

Sorry for the inconvenience. Could you please provide more details?

The following code works in 5.9.1:

import com.kms.katalon.core.logging.KeywordLogger
logger.logInfo("test")KeywordLogger logger = new KeywordLogger()

I’m also having this issue in 5.9.1, but even with the built-in keywords WS.comment(), Mobile.comment(), WebUI.comment(). I see the line in the console and log, but nothing is actually logged.

Alex said:

The following code works in 5.9.1:

import com.kms.katalon.core.logging.KeywordLogger

logger.logInfo(“test”)KeywordLogger logger = new KeywordLogger()


  

Hi Alex,

please excuse me, you’re absolutely right! I don’t know what I did differently yesterday, but now it works for me.

And on that occasion I registered the following warning in the console log now:

Please use “KeywordUtil.logInfo()” instead of “new KeywordLogger()” constructor. “KeywordLogger” is an internal API and might be changed in the future.

In fact, I didn’t even know about these KeywordUtil logging methods, which are also easier to use than the internal KeywordLogger, because it works immediately without having to create a new instance first. Thank you for pointing this out to me! :slight_smile:

Nevertheless, a small point of criticism regarding the new console log (maybe a bit off-topic):

This is now very clearly structured, but the output text can no longer be easily copied and shared because it contains a lot of non-printable characters. Maybe these could be removed/replaced automatically when copying to the clipboard?

1 Like

Hi all

Small question regarding the KeywordUtil.log…() (or in this case KeywordUtil.mark…())-keyword:
Currently (with Version 5.9.1) using KeywordUtil.markFailed(“someString”) will not mark the step as failed in the logs. One needs to implement the a KeywordLogger() as well to get the logs updated.

For instance I have the following Test case:

import com.kms.katalon.core.util.KeywordUtil
import models.checkKeywordUtil
checkKeywordUtil.testKeyWordUtil("Test1")
checkKeywordUtil.testKeyWordUtilWithOtherStep("Test2")
checkKeywordUtil.testKeyWordUtilWithLogger("Test3")
checkKeywordUtil.testKeyWordUtilWithLoggerAndOtherStep("Test4")
KeywordUtil.markFailed("Test5")if(true){	KeywordUtil.markFailed("Test6")}System.println("Done")

Using the Custom-Keywords:

package modelspublic class checkKeywordUtil{
	@Keyword
	public static void testKeyWordUtil(String message){
		KeywordUtil.markFailed(message)	}	@Keyword	public static void testKeyWordUtilWithOtherStep(String message){		WebUI.openBrowser('')		WebUI.closeBrowser()		KeywordUtil.markFailed(message)	}	@Keyword	public static void testKeyWordUtilWithLogger(String message){		KeywordLogger log = new KeywordLogger()		KeywordUtil.markFailed(message)		log.logFailed(message)	}	@Keyword	public static void testKeyWordUtilWithLoggerAndOtherStep(String message){		KeywordLogger log = new KeywordLogger()		WebUI.openBrowser('')		WebUI.closeBrowser()		KeywordUtil.markFailed(message)		log.logFailed(message)	}}

From the test case above only Test 3 and 4 will be marked as failed, Test 1,5 and 6 will not be marked at all and Test 2 will even been marked as passed in the logs:

Hence, in order to get the logs updated shall we still use the new KeywordLogger() - Constructor or will this be something the KeywordUtil.mark…() will be able to handle in the future?

Many thanks in advance for your answer.

Hi all

Small question regarding the KeywordUtil.log…() (or in this case KeywordUtil.mark…())-keyword:
Currently (with Version 5.9.1) using KeywordUtil.markFailed(“someString”) will not mark the step as failed in the logs. One needs to implement the a KeywordLogger() as well to get the logs updated.

For instance I have the following Test case:

import com.kms.katalon.core.util.KeywordUtil
import models.checkKeywordUtil
checkKeywordUtil.testKeyWordUtil("Test1")
checkKeywordUtil.testKeyWordUtilWithOtherStep("Test2")
checkKeywordUtil.testKeyWordUtilWithLogger("Test3")
checkKeywordUtil.testKeyWordUtilWithLoggerAndOtherStep("Test4")
KeywordUtil.markFailed("Test5")if(true){	KeywordUtil.markFailed("Test6")}System.println("Done")

Using the Custom-Keywords:

package modelspublic class checkKeywordUtil{
	@Keyword
	public static void testKeyWordUtil(String message){
		KeywordUtil.markFailed(message)	}	@Keyword	public static void testKeyWordUtilWithOtherStep(String message){		WebUI.openBrowser('')		WebUI.closeBrowser()		KeywordUtil.markFailed(message)	}	@Keyword	public static void testKeyWordUtilWithLogger(String message){		KeywordLogger log = new KeywordLogger()		KeywordUtil.markFailed(message)		log.logFailed(message)	}	@Keyword	public static void testKeyWordUtilWithLoggerAndOtherStep(String message){		KeywordLogger log = new KeywordLogger()		WebUI.openBrowser('')		WebUI.closeBrowser()		KeywordUtil.markFailed(message)		log.logFailed(message)	}}

From the test case above only Test 3 and 4 will be marked as failed, Test 1,5 and 6 will not be marked at all and Test 2 will even been marked as passed in the logs:

Hence, in order to get the logs updated shall we still use the new KeywordLogger() - Constructor or will this be something the KeywordUtil.mark…() will be able to handle in the future?

Many thanks in advance for your answer.

1 Like

Thank you for the feedback. We will fix the issue with non-printable characters.

Thank you for the question - this is a use case we didn’t notice. We will improve the KeywordUtil in future releases.