Proper functional / acceptance test structure

I am currently working on creating an automated set of functional / acceptance tests for the project, but I do not have much experience writing these types of tests, so I wanted to get some input into their correct structuring. In particular, I work with the Arkillian Graphene extension.

For example, let's say I have 3 tests: A, B and C.

TestA . Tests are registered in the account in the application. So, if the test was successful, the browser should be on the account’s home / information page.

TestB : tests that change the account password. To do this, you need to log in to your account, and then check the functionality of changing the password.

TestC : tests that modify the email account. This again requires you to log in to your account and then verify the functionality of the email change.

If TestA fails due to a problem with the login code, it is obvious that TestB and TestC should also fail because they require an account login.

Question . Should automatic functional / acceptance tests duplicate the process required to complete a test verification? In this case, TestB and TestC must log in to the account before doing anything else. If each test explicitly calls something like:

/* ...initial test setup code here */
LoginPage.login(username, password);
assertTrue(onCorrectAccountPage);
AccountModification.changePassword(newPassword);

Or should I use some way to mock the account in the session that can be used in tests B and C so that they don't fail, even if TestA (the actual login test)?

, , , , , , , - (.. , unit test), -, .

. , .:)

+5
3

, , , . , TestA: , -, , (, ), TestB: , -, , .

TestA TestB - . A , , , B , . ?

, B, A ?

, - , - , , - .

. , , , - . , - .

+4

, , . , , (, ). , (+1!). , , , , , , , . , , . , , , , , , , , " ".

, . , . , - . , , , , , , "", , , . , , , , ( :)).

, , , , , , . , , . , , :)

+3

, , .

, unit test : TestA - : TestB , , .

JUnit can be used assumeTrueinstead assertTruefor this purpose. Thus, your TestB will become:

/* ...initial test setup code here */
LoginPage.login(username, password);
assumeTrue(onCorrectAccountPage);
AccountModification.changePassword(newPassword);

Now, if errTrue fails, the test is simply ignored. However, your TestA will still fail, letting you and your end user know what the real problem is.

+1
source

All Articles