I have made a number of test cases on PHPUnit for Browser testing of the website, all these tests pass when I run them individually , but when I try to run them as a group or using php artisan dusk
command, some of them fail. The real problem is that whenever I run them together, error occurs in different test cases every time.
I searched it on the internet and found RefreshDatabase
and DatabaseTransaction
commands but I can't use them as it is not a suitable solution and also not allowed by my colleagues. Kindly let me know what I'm missing or what else I should add in order to run all the tests smoothly.
P.S.I want to run them together for Auto-deployment on servers (testing and then deploying the changes)
Below is an example test for clear understanding of the issue:
<?php
namespace TestsBrowser;
use TestsDuskTestCase;
use LaravelDuskBrowser;
use IlluminateFoundationTestingDatabaseMigrations;
class AddUsrSegmentTest extends DuskTestCase
{
/**
* create a user segment
*
* @return void
* @group other
*/
public function testExample()
{
$this->browse(function (Browser $browser) {
$browser->loginAs(AppModelUser::find(4567))
->visit('/home')
->clickLink('Create From Scratch')
->assertPathis('/bot/dashboard')
//first create a user datastore
->visit('/bot/datastore')
->assertSee('Create a Global/User Datastore')
->visit('/bot/datastore/create')
->assertSee('Custom Values')
->click('#showCustomInput')
->type('key','colorsss')
//->type('.bootstrap-tagsinput > input:nth-child(1)','apple')
//->keys('.bootstrap-tagsinput > input:nth-child(1)','mango', ['{enter}'])
->keys('.bootstrap-tagsinput > input:nth-child(1)','green', ['{enter}'],'mustard',['{enter}'],'blue',['{enter}'],'red',['{enter}'])
->click('.slider')
->assertSee('Add Datastore')
->click('button.btn:nth-child(1)')// add datastore button
->visit('/bot/datastore')
->assertSeeIn('#zero-config','colorsss')
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…