Maven & GIT Interview Questions Flashcards

1
Q

How can you make sure that all team members are using the same Selenium version?

A

Use tools like Maven that give version and build control for team perspective and have the same version in pom.xml

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Maven?

A

Maven is a build automation tool or a project management tool. In Maven we have many inbuilt templates. These templates are called archetypes.

As automation engineers using Maven, we can create project structure, manage project required dependencies and execute script from command line interface (CLI)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is POM.XML?

A

POM stands for “Project Object Model”

The pom.xml file contains information of project and project configuration information for Maven to build the project such as dependencies, build directory, source directory, test source directory, plugin, goals etc.

Maven reads the pom.xml file then executes the goal.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the Maven Repository? What are their types?

A

Maven repository is a location where all the project jars, library jars, plugins or any other particular project related artifacts are stored and can be easily used by Maven.

Maven repository types:
● local - repository inside your computer (.M2)
● central (https://mvnrepository.com/)
● remote - developer’s own custom repository containing required libraries or other project jars.

For example, in a corporate office there may be projects or modules specific to the organization. In this case, organizations can create remote repositories and deploy these private artifacts.

This remote repository will be accessible only inside the organization.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is dependency and how to handle dependencies in a framework?

A

In Maven we have dependencies. A dependency is a JAR file which will be added to the classpath. While executing the tasks we are going to update the dependencies in the POM.xml which is the heart of Maven project.

We use dependencies in our framework because of compatibility issues as we work in a team. For example, if the Selenium Webdriver version is not supported, we can simply update the dependency file with a different version.

Here we can simply change the version according to the compatibility.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you submit plugins in Maven? What are they? Version?

A

Maven Plugins are generally used to:

● Maven compiler plugin - compile code files
● Maven surefire plugin - is used during the test phase of the build lifecycle to execute the unit tests of an application

A plugin provides a set of goals, which can be executed using the following syntax:

mvn [plugin-name]:[goal-name]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

List out some Maven build phases?

A

The following are the phases:

● validate − validate the project is correct and all necessary information is available.
● compile − compile the source code of the project.
● test − test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed
● package − take the compiled code and package it in its distributable format, such as a JAR.
● integration-test − process and deploy the package if necessary into an environment where integration tests can be run.
● verify − run any checks to verify the package is valid and meets quality criteria.
● install − install the package into the local repository, for use as a dependency in other projects locally.
● deploy − done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What type of version control do you use?

A

Version Control is essential to development, even if you’re working by yourself because it protects you from yourself. If you make a mistake, it’s a simple matter to roll back to a previous version of your code that you know works. This also frees you to explore and experiment with your code because you’re free of worries about whether what you’re doing is reversible or not.

We have used Maven for build generation and Git for version control.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Explain what is a Maven artifact?

A

Usually, an artifact is a JAR file which gets arrayed to a Maven repository. One or more artifacts a Maven build produces includes a compiled JAR and a sources JAR. Each artifact includes a group ID, an artifact ID and a version string.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is GIT?

A

GIT is a distributed version control system and source code management (SCM) system with an emphasis to handle small and large projects with speed and efficiency.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
  1. What is the function of git clone?
A

The git clone command creates a copy of an existing Git repository. To get a copy of a central repository, ‘cloning’ is the most common method used by programmers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
  1. What is the function of ‘git config’?
A

The ‘git config’ command is a convenient way to set configuration options for your Git installation. Behavior of a repository, user info, preferences etc. can be defined through this command.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can you create a repository in Git?

A

In Git, to create a repository, create a directory for the project if it does not exist, and then run command “git init”. By running this command, the .git directory will be created in the project directory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a ‘conflict’ in git?

A

A ‘conflict’ arises when the commit that has to be merged has some change in one place, and the current commit also has a change at the same place. Git will not be able to predict which change should take precedence.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is ‘git status’ used for?

A

As ‘git status’ shows you the difference between the working directory and the index, it is helpful in understanding GIT more comprehensively.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Explain Git Workflow?

A

GIT provides three key areas that are uniquely designed to give developers lots of control over workflow:

  1. Working directory: contains all the current states of files. Numerous developers can access the directory when they are logged in, so collaboration is extremely easy.
  2. Staging Area: indexes everything for the next commit and any files that have been added or edited since the previous save.
  3. GIT repository: dedicated space where new commits are added. The GIT repository maintains all the metadata, the files and a dedicated database that tracks versions of the project.
17
Q
  1. What are the advantages of using GIT?
A
● Data redundancy and replication
● Any sort of projects can use GIT
● High availability
● Only one .git directory per repository
● Superior disk utilization and network performance
● Collaboration friendly
18
Q

What are the commands for your version control?

A
● git add
● git status
● git commit
● git push
● git pull
19
Q

What is the difference between commit and push?

A

git commit “records changes” to the repository while git push “updates” the remote repository

20
Q

How do you see who updated the class file using GIT?

A

Using “git log” command

21
Q

What is staging in GIT?

A

The staging area is a file, generally contained in your GIT directory that stores information about what will go into your next commit. Its technical name in GIT parlance is the “index”, but the phrase “staging area” works just as well.

The basic GIT workflow goes something like this:

  1. Modify files in your working tree.
  2. Selectively stage those changes you want to be part of your next commit, which adds only those changes to the staging area.
  3. You do a commit which takes the files as they are in the staging area and stores that snapshot permanently to your GIT directory.
22
Q

Simple rules for less merge conflicts.

A

Constantly pull changes:
From master or the branch that you are working on before making any changes to your project.

Updating your branch with master branch:
Merging master branch into your active branch insures, your active branch has the latest changes from the master branch.

Short-Living Branches:
Many big merge conflicts are results of long-living branches. If you work in your own branch for several days, or even weeks, the risk is high that someone else changes parts of the code you have touched in another branch. That would lead to merge conflicts. On the other hand, if you have a short-living branch, meaning it is merged back into the trunk or master branch after a few hours, there will probably be no merge conflict. Even if there is a conflict, it can usually be resolved very quickly because there is much less code to think about. The following figures both show a master branch (the line in the middle) and some kind of feature branches. The difference between those figures is that the first one contains many short-living branches while the second one has only two long-living feature branches. The merge commits in the first figure are always green because the short branches have not caused any merge conflicts. In the second figure we have a red dot at the end which represents a merge conflict that was caused by two of the many commits in the long-living branches.

Small Modules:
The Single Responsibility Principle (which is part of the SOLID principles of software design) says that “a class should have one, and only one, reason to change“. If we take this approach seriously, there should never be a situation in which two developers change the same code at the same time because that would mean they are working on the same
task. You see, a modular architecture and small classes do not only help to increase the
quality of the code design but also decrease the chance for merge conflicts.

Strong Communication:
“Communication is the key” – We have heard this phrase so many times… and it’s true!
If all your teammates know what you are working on and which parts of the code you are touching they will try not to change the same code at the same time. If another developer wants to change a part of the code base which you are working on then it would probably be a good idea to work together

23
Q

Explain what is head in terms of GIT and also tell the number of heads that can be present in a repository?

A

A head is nothing but a reference to the last commit object of a branch. For every repository, there will always be a default head referred to as “master” or now “main” (as per GitHub) but there is no restriction to the count of heads available. In other words, it can have any number of heads.

24
Q

What is GIT stash?

A

GIT stash can be used in cases where we need to switch in between branches and at the same time not wanting to lose edits in the current branch.

Running the GIT stash command basically pushes the current working directory state and index to the stack for future use and thereby providing a clean working directory for other tasks