Skip to content

Commit 2af76c7

Browse files
committed
final project
1 parent de4adc4 commit 2af76c7

File tree

2 files changed

+84
-75
lines changed

2 files changed

+84
-75
lines changed

Makefile

Lines changed: 51 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,58 @@
1-
# Builds an environment for Cucumber, Selenium, and Firefox
2-
3-
.PHONY: all help cucumber app clean
1+
.PHONY: all help install build run
42

53
help: ## Display this help
64
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-\\.]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
75

86
all: help
97

10-
cucumber: ## Install pre-requisite software for Cucumber/Java
11-
$(info Install Cucumber/Java prerequisite software...)
12-
sudo apt-get update
13-
sudo apt-get install -y openjdk-21-jdk maven firefox
14-
# Install GeckoDriver for Firefox
15-
wget https://github.com/mozilla/geckodriver/releases/download/v0.33.0/geckodriver-v0.33.0-linux64.tar.gz
16-
tar -xvzf geckodriver-v0.33.0-linux64.tar.gz
17-
sudo mv geckodriver /usr/local/bin/
18-
sudo chmod +x /usr/local/bin/geckodriver
19-
rm geckodriver-v0.33.0-linux64.tar.gz
20-
21-
app: ## Run the Petshop application
22-
$(info Running Petshop Application...)
23-
docker run -d --name petshop \
24-
-p 8080:8080 \
25-
-e DATABASE_URI=sqlite:///test.db \
26-
rofrano/lab-flask-bdd:1.0
27-
28-
clean: ## Stop and remove the container
29-
$(info Stopping and removing container...)
30-
docker stop petshop || true
31-
docker rm petshop || true
32-
33-
test: ## Run Cucumber tests
8+
.PHONY: build
9+
build: ## Build a Docker image
10+
$(info Building Docker image...)
11+
docker build --rm --pull --tag products:1.0 .
12+
13+
install: ## Install Java dependencies
14+
$(info Installing dependencies...)
15+
./mvnw dependency:resolve
16+
17+
lint: ## Run the linter
18+
$(info Running linting...)
19+
./mvnw checkstyle:check
20+
21+
.PHONY: tests
22+
tests: ## Run the unit tests
23+
$(info Running tests...)
24+
./mvnw test
25+
26+
.PHONY: integration-tests
27+
integration-tests: ## Run integration tests
28+
$(info Running integration tests...)
29+
./mvnw verify -P integration-test
30+
31+
run: ## Run the service
32+
$(info Starting service...)
33+
./mvnw spring-boot:run
34+
35+
dbrm: ## Stop and remove PostgreSQL in Docker
36+
$(info Stopping and removing PostgreSQL...)
37+
-docker stop postgres
38+
-docker rm postgres
39+
40+
db: ## Run PostgreSQL in Docker
41+
$(info Running PostgreSQL...)
42+
docker run -d --name postgres \
43+
-p 5432:5432 \
44+
-e POSTGRES_PASSWORD=postgres \
45+
-v postgres:/var/lib/postgresql/data \
46+
postgres:alpine
47+
48+
clean: ## Clean the project
49+
$(info Cleaning the project...)
50+
./mvnw clean
51+
52+
package: ## Package the application
53+
$(info Packaging the application...)
54+
./mvnw package
55+
56+
cucumber: ## Run Cucumber BDD tests
3457
$(info Running Cucumber tests...)
35-
mvn clean test
58+
./mvnw test -Dtest=CucumberTestRunner

bin/setup.sh

Lines changed: 33 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,44 @@
11
#!/bin/bash
2-
echo "****************************************"
3-
echo " Setting up Cucumber/Java Environment"
4-
echo "****************************************"
5-
6-
echo "Checking and installing Java 21..."
7-
if type -p java; then
8-
java_version=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}')
9-
if [[ $java_version == 21* ]]; then
10-
echo "Java 21 is already installed"
11-
else
12-
echo "Installing Java 21..."
13-
sudo apt-get update
14-
sudo apt-get install -y openjdk-21-jdk
15-
fi
16-
else
17-
echo "Installing Java 21..."
18-
sudo apt-get update
19-
sudo apt-get install -y openjdk-21-jdk
20-
fi
21-
22-
echo "Checking Java version..."
23-
java -version
24-
25-
echo "Installing Maven..."
26-
sudo apt-get install -y maven
27-
28-
echo "Checking Maven version..."
29-
mvn --version
30-
31-
echo "Configuring the developer environment..."
32-
echo "# Cucumber/Java Lab Additions" >> ~/.bashrc
2+
echo "**************************************************"
3+
echo " Setting up TDD/BDD Final Project Environment"
4+
echo "**************************************************"
5+
6+
echo "*** Installing Java 21 and tools"
7+
sudo apt-get update
8+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y openjdk-21-jdk maven
9+
10+
echo "*** Checking the Java version..."
11+
java --version
12+
13+
echo "*** Configuring the developer environment..."
14+
echo "# TDD/BDD Final Project additions" >> ~/.bashrc
15+
echo "export GITHUB_ACCOUNT=$GITHUB_ACCOUNT" >> ~/.bashrc
3316
echo 'export PS1="\[\e]0;\u:\W\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]\$ "' >> ~/.bashrc
34-
echo "export PATH=$HOME/local/bin:$PATH" >> ~/.bashrc
3517
echo "export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64" >> ~/.bashrc
18+
echo "export PATH=\$PATH:\$JAVA_HOME/bin" >> ~/.bashrc
3619

37-
echo "Installing Firefox and GeckoDriver for Selenium"
20+
echo "*** Installing Selenium and Chrome for BDD"
3821
sudo apt-get update
39-
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y firefox
22+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y sqlite3 ca-certificates chromium-driver
23+
24+
echo "*** Installing Maven wrapper..."
25+
mvn -N io.takari:maven:wrapper -Dmaven=3.8.6
4026

41-
# Install GeckoDriver
42-
GECKO_VERSION="v0.33.0"
43-
wget https://github.com/mozilla/geckodriver/releases/download/${GECKO_VERSION}/geckodriver-${GECKO_VERSION}-linux64.tar.gz
44-
tar -xvzf geckodriver-${GECKO_VERSION}-linux64.tar.gz
45-
sudo mv geckodriver /usr/local/bin/
46-
sudo chmod +x /usr/local/bin/geckodriver
47-
rm geckodriver-${GECKO_VERSION}-linux64.tar.gz
27+
echo "*** Establishing application.properties file"
28+
cp src/main/resources/application-example.properties src/main/resources/application.properties
4829

49-
echo "Starting the Petshop Docker container..."
50-
make app
30+
echo "*** Starting the Postgres Docker container..."
31+
make db
5132

52-
echo "Checking the Petshop Docker container..."
33+
echo "*** Checking the Postgres Docker container..."
5334
docker ps
5435

55-
echo "****************************************"
56-
echo " Cucumber/Java Environment Setup Complete"
57-
echo "****************************************"
36+
echo "*** Building the project..."
37+
./mvnw clean package -DskipTests
38+
39+
echo "**************************************************"
40+
echo " TDD/BDD Final Project Environment Setup Complete"
41+
echo "**************************************************"
42+
echo ""
43+
echo "Use 'exit' to close this terminal and open a new one to initialize the environment"
5844
echo ""

0 commit comments

Comments
 (0)