Skip to content

Sample test classes write files into the subproject's root directory so that the file trees get dirty #8

@kazurayam

Description

@kazurayam

The following graph shows the tree of a project root directory which contains multiple subprojects:

:~/github/selenium-webdriver-java (kazurayam8)
$ tree -L 2 .
.

├── selenium-ide
│   └── hello-selenium-ide.side
├── selenium-webdriver-junit4
│   ├── build
│   ├── build.gradle
│   ├── gradle
│   ├── gradlew
│   ├── gradlew.bat
│   ├── pom.xml
│   ├── src
│   └── target
├── selenium-webdriver-junit5
│   ├── build.gradle
│   ├── gradle
│   ├── gradlew
│   ├── gradlew.bat
│   ├── pom.xml
│   └── src
├── selenium-webdriver-junit5-seljup
│   ├── build.gradle
│   ├── gradle
│   ├── gradlew
│   ├── gradlew.bat
│   ├── pom.xml
│   └── src
├── selenium-webdriver-testng
│   ├── build.gradle
│   ├── gradle
│   ├── gradlew
│   ├── gradlew.bat
│   ├── pom.xml
│   └── src
├── settings.gradle

Then I executed all tests of the subprojects.

$ ./gradlew clean test

When all tests finished, I viewed the directory tree under a subproject selenium-webdriver-junit4

.
├── 2023.10.24_22.07.27.742-7440524241d0dbd63ca5eec377b6455c.png    --- x
├── 2023.10.24_22.07.29.333-7440524241d0dbd63ca5eec377b6455c.png    --- x
├── build
│   ├── allure-results
│   ├── classes
│   ├── downloads
│   ├── generated
│   ├── reports
│   ├── resources
│   ├── test-results
│   └── tmp
├── build.gradle
├── extentReport.html    --- x
├── fullpage-screenshot-chrome.png    --- x
├── gradle
│   └── wrapper
├── gradlew
├── gradlew.bat
├── login.har    --- x
├── my-pdf.pdf    --- x
├── pom.xml
├── screenshot.png    --- x
├── src
│   ├── main
│   └── test
├── target
│   ├── classes
│   ├── generated-sources
│   ├── generated-test-sources
│   ├── maven-status
│   └── test-classes
├── testAccessibility.json    --- x
├── webdrivermanager.pdf    --- x
├── webdrivermanager.png    --- x
└── webelement-screenshot.png    --- x

20 directories, 15 files

I found a lot of new files under the subproject's root directory. I executed git status command to find the new files:

$ git status
On branch kazurayam8
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        2023.10.24_22.07.27.742-7440524241d0dbd63ca5eec377b6455c.png
        2023.10.24_22.07.29.333-7440524241d0dbd63ca5eec377b6455c.png
        extentReport.html
        fullpage-screenshot-chrome.png
        login.har
        my-pdf.pdf
        screenshot.png
        testAccessibility.json
        webdrivermanager.pdf
        webdrivermanager.png
        webelement-screenshot.png

These new files are not gitignored. Therefore if I carelessly do the following operation:

$ git add .
$ git commit -m "save changes"

then the newl files will be commited into the project tree. A disastrous plution of the project tree!

The sample tests in the book should not write files into the project's root directory. The tests should write files into a particular directory in the project's root directory.

And I want to list the directroy in the .gitignore file so that Git ignores all the test outputs silently.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions