Skip to content

Commit

Permalink
fix(test): Upgrade to JUnit5 and Kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
djansen-redhat committed Aug 29, 2018
1 parent 3100567 commit 360d720
Show file tree
Hide file tree
Showing 144 changed files with 6,778 additions and 7,602 deletions.
2 changes: 1 addition & 1 deletion server/functional-test/README.md
Expand Up @@ -61,7 +61,7 @@ public class RegisterTest extends ZanataTestCase {
Map<String, String> fields;
private HomePage homePage;
@Before
@BeforeEach
public void before() {
// fields contains a set of data that can be successfully registered
fields = new HashMap<String, String>();
Expand Down
18 changes: 17 additions & 1 deletion server/functional-test/pom.xml
Expand Up @@ -304,6 +304,23 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.2.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-migrationsupport</artifactId>
<version>5.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand All @@ -312,7 +329,6 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>

<dependency>
<groupId>org.subethamail</groupId>
<artifactId>subethasmtp</artifactId>
Expand Down
Expand Up @@ -125,7 +125,7 @@ private List<WebElement> getWebhookList() {
return listWrapper.get(0).findElements(By.className("list-item"));
}

static class WebhookItem {
public static class WebhookItem {
private String url;
private List<String> types;

Expand Down
Expand Up @@ -22,7 +22,7 @@ package org.zanata

import org.junit.Rule
import org.junit.Test
import org.zanata.util.SampleDataRule
import org.zanata.util.SampleDataExtension

/**
* This is a class for experiment some things i.e. populate cargo instance with
Expand All @@ -31,7 +31,7 @@ import org.zanata.util.SampleDataRule
*/
class ExperimentTest {
@get:Rule
var sampleDataRule = SampleDataRule()
var sampleDataRule = SampleDataExtension()

@Test
fun test() {
Expand Down

This file was deleted.

Expand Up @@ -20,34 +20,34 @@
*/
package org.zanata.feature.account

import org.junit.Before
import org.junit.Test
import org.junit.experimental.categories.Category
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.zanata.feature.Trace
import org.zanata.feature.testharness.TestPlan.DetailedTest
import org.zanata.feature.testharness.DetailedTest
import org.zanata.feature.testharness.ZanataTestCase
import org.zanata.page.dashboard.dashboardsettings.DashboardAccountTab
import org.zanata.workflow.BasicWorkFlow
import org.zanata.workflow.LoginWorkFlow

import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.DisplayName

/**
* @author Damian Jansen [djansen@redhat.com](mailto:djansen@redhat.com)
*/
@Category(DetailedTest::class)
@DetailedTest
class ChangePasswordTest : ZanataTestCase() {

@Before
@BeforeEach
fun setUp() {
BasicWorkFlow().goToHome().deleteCookiesAndRefresh()
}

@Trace(summary = "The user can change their password",
testCaseIds = [5704])
@Test(timeout = MAX_SHORT_TEST_DURATION.toLong())
@Throws(Exception::class)
fun changePasswordSuccessful() {
@Test
@DisplayName("Change the users password")
fun `Change the users password`() {
val dashboard = LoginWorkFlow()
.signIn("translator", "translator")
.goToSettingsTab()
Expand All @@ -71,9 +71,9 @@ class ChangePasswordTest : ZanataTestCase() {
}

@Trace(summary = "The user must enter their current password correctly to change it")
@Test(timeout = MAX_SHORT_TEST_DURATION.toLong())
@Throws(Exception::class)
fun changePasswordCurrentPasswordFailure() {
@Test
@DisplayName("Change password fails with incorrect current password")
fun `Change password fails with incorrect current password`() {
val dashboardAccountTab = LoginWorkFlow()
.signIn("translator", "translator")
.goToSettingsTab()
Expand All @@ -88,9 +88,9 @@ class ChangePasswordTest : ZanataTestCase() {
}

@Trace(summary = "The user must enter a non-empty new password to change it")
@Test(timeout = MAX_SHORT_TEST_DURATION.toLong())
@Throws(Exception::class)
fun changePasswordRequiredFieldsAreNotEmpty() {
@Test
@DisplayName("Change password fails on empty new password")
fun `Change password fails on empty new password`() {
val dashboardAccountTab = LoginWorkFlow()
.signIn("translator", "translator")
.goToSettingsTab()
Expand All @@ -104,9 +104,9 @@ class ChangePasswordTest : ZanataTestCase() {

@Trace(summary = "The user must enter a new password of between 6 and " +
"1024 characters in length to change it")
@Test(timeout = MAX_SHORT_TEST_DURATION.toLong())
@Throws(Exception::class)
fun changePasswordAreOfRequiredLength() {
@Test
@DisplayName("Change password fails when too short")
fun `Change password fails when too short`() {
val tooShort = "test5"
val dashboardAccountTab = LoginWorkFlow()
.signIn("translator", "translator")
Expand Down
Expand Up @@ -20,12 +20,10 @@
*/
package org.zanata.feature.account

import org.junit.Before
import org.junit.BeforeClass
import org.junit.Test
import org.junit.experimental.categories.Category
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test
import org.zanata.feature.Trace
import org.zanata.feature.testharness.TestPlan.DetailedTest
import org.zanata.feature.testharness.DetailedTest
import org.zanata.feature.testharness.ZanataTestCase
import org.zanata.page.account.RegisterPage
import org.zanata.workflow.BasicWorkFlow
Expand All @@ -34,68 +32,59 @@ import org.assertj.core.api.Assertions.assertThat
/**
* @author Damian Jansen [djansen@redhat.com](mailto:djansen@redhat.com)
*/
@Category(DetailedTest::class)
@DetailedTest
class EmailValidationTest : ZanataTestCase() {

private var registerPage: RegisterPage? = null
private lateinit var registerPage: RegisterPage

@Before
fun before() {
registerPage = BasicWorkFlow().goToHome().goToRegistration()
private fun goToRegister(): RegisterPage {
return BasicWorkFlow().goToHome().goToRegistration()
}

@Trace(summary = "The system will allow acceptable forms of an email " +
"address for registration",
testPlanIds = [5681], testCaseIds = [-1])
@Test(timeout = MAX_SHORT_TEST_DURATION.toLong())
@Throws(Exception::class)
fun validEmailAcceptance() {
registerPage = registerPage!!.enterEmail("me@mydomain.com")
registerPage!!.defocus()
@Test
@DisplayName("Valid emails are accepted")
fun `Valid emails are accepted`() {
registerPage = goToRegister().enterEmail("me@mydomain.com")
registerPage.defocus()

assertThat(registerPage!!.errors)
.`as`("Email validation errors are not shown").isEmpty()
assertThat(registerPage.errors)
.describedAs("Email validation errors are not shown").isEmpty()
}

@Trace(summary = "The user must provide a valid email address to " +
"register with Zanata", testPlanIds = [5681], testCaseIds = [5691])
@Test(timeout = MAX_SHORT_TEST_DURATION.toLong())
@Throws(Exception::class)
fun invalidEmailRejection() {
registerPage = registerPage!!.enterEmail("notproper@").registerFailure()
@Test
@DisplayName("Invalid emails are rejected")
fun `Invalid emails are rejected`() {
registerPage = goToRegister().enterEmail("notproper@").registerFailure()

assertThat(registerPage!!.errors)
.`as`("The email formation error is displayed")
assertThat(registerPage.errors)
.describedAs("The email formation error is displayed")
.contains(RegisterPage.MALFORMED_EMAIL_ERROR)

registerPage = registerPage!!.clearFields()
registerPage = registerPage.clearFields()
.enterEmail("admin@example.com")
.registerFailure()

assertThat(registerPage!!.errors)
.`as`("The user needs to provide a unique email address")
assertThat(registerPage.errors)
.describedAs("The user needs to provide a unique email address")
.contains(RegisterPage.EMAIL_TAKEN)
}

@Trace(summary = "The user must provide a unique email address to " +
"register with Zanata", testPlanIds = [5681], testCaseIds = [5691])
@Test(timeout = MAX_SHORT_TEST_DURATION.toLong())
@Throws(Exception::class)
fun nonUniqueEmailRejection() {
registerPage = registerPage!!.enterEmail("admin@example.com")
@Test
@DisplayName("Already taken emails are rejected")
fun `Already taken emails are rejected`() {
registerPage = goToRegister().enterEmail("admin@example.com")
.registerFailure()

assertThat(registerPage!!.errors)
.`as`("The user needs to provide a unique email address")
assertThat(registerPage.errors)
.describedAs("The user needs to provide a unique email address")
.contains(RegisterPage.EMAIL_TAKEN)
}

companion object {

@BeforeClass
fun setUp() {
// Ensure no login
BasicWorkFlow().goToHome().deleteCookiesAndRefresh()
}
}
}

0 comments on commit 360d720

Please sign in to comment.