You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hey there,
i am using Scriptrunner restendpoints, which i want to unittest using the Spockframework as described here: [Adaptavist] Testing your Code
Putting the tests into the scriptroot and then executing it via the ui works like a charme.
When trying to run them from IntelliJ i always stumble into the following exception:
java.lang.Exception: No tests found matching method name filter from org.junit.runner.Request$1@3af039ed
at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:40)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at org.junit.runner.JUnitCore$run$0.call(Unknown Source)
at com.onresolve.scriptrunner.canned.common.admin.RunUnitTests.doScript(RunUnitTests.groovy:320)
Anyone can help me resolving that issue?
IntelliJ Configuration:
Testcode:
package X.X.X
import com.atlassian.core.user.preferences.Preferences
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.preferences.UserPreferencesManager
import com.onresolve.scriptrunner.canned.common.admin.ScriptRunnerTestRunner
import com.onresolve.scriptrunner.canned.common.admin.SrSpecification
import org.junit.runner.RunWith
@RunWith(ScriptRunnerTestRunner)
class ChangeLanguageTest extends SrSpecification {
def "Process"() {
setup: "create temporarily user and generate test data"
final String locale
// Check if DefaultUserLocale is de_DE. If switch locale to en_US, so that the test will still work
if (ComponentAccessor.applicationProperties.defaultLocale.toString() == "de_DE"){
locale ="en_US"
}
else {
locale ="de_DE"
}
//Create test user
final String username = "changeLanguageTestUser"
ComponentAccessor.userUtil.createUserNoNotification(username,"",username +"@test.com",username)
//Generate userLanguageJSON
final String userLanguageJson = "{\n" +
" \"language\": [{\n" +
" \"username\": \"" + username + "\",\n" +
" \"language\": \"" +locale + "\"" +
" }]\n" +
" }"
when: "instantiating changeLanguage and executing process"
new LanguageChanger(userLanguageJson).process()
then: "users locale should be de_DE"
final ApplicationUser user = ComponentAccessor.userManager.getUserByName(username)
final Preferences userPreferences = ((UserPreferencesManager) ComponentAccessor.getOSGiComponentInstanceOfType(UserPreferencesManager.class)).getPreferences(user)
final String currentLanguageLocale = userPreferences.getString("jira.user.locale")
currentLanguageLocale == locale
cleanup: "delete all test artifacts"
//Jira does not remove the locale after deleting the user (seems that it is somehow bound to the username)
// that means that it is necessary to delete the userPreference "jira.user.locale" manually, so that a default will be set again.
userPreferences.remove("jira.user.locale")
ComponentAccessor.userUtil.removeUser(ComponentAccessor.jiraAuthenticationContext.loggedInUser, user)
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.