testng


My TestNG.xml leads to execution of #BeforeTest method even if there are no tests eligible for execution in that class


My TestNG.xml comprises of set of this kind of tag:-
<test name="Order">
<groups>
<run>
<include name="Smoke" />
<exclude name="Regression"></exclude>
</run>
</groups>
<classes>
<class name="com.test.myproject.class1"/>
</classes>
</test>
What is happening is Some of the classes only have Regression group names and no Smoke name. So, I was expecting that nothing of those classes should be executed. But, I can see the BeforeTest and AfterTest of these classes getting executed even though none of the tests are eligible to be executed.
Any tip on how can I not allow BeforeTest and AfterTest from getting executed?
I am using TestNG 6.9.9
Here is how my java testng code looks:-
#Listeners(AUTEventListener.class)
public class MyTest extends BaseTestCase {
#Parameters({ "browserName", "gridHubUrl", "gridNodeUrl" })
#BeforeTest(alwaysRun = true)
public void testInit(String browserName, String gridHubUrl, String gridNodeUrl) throws Exception {
//Before Test logic is here
}
#BeforeMethod(alwaysRun = true)
public void openBrowser() {
//BeforeMethod logic is here
}
#Test(priority = 1, groups={"Regression"}, description = "Testcase to Verify that a claimant is able to file a non cargo claim")
#TestInfo(testcaseIds={"TC-12344"})
public void TC_12344_MyTestMethod() throws Exception
{
// Test is here
}

Related Links

testng data provider display current test number
TestNG how to pass a URL as a parameter?
Unable to run testng from command line
TestNG parallel execution
How to send TestNG emailable report through mail
How to run testng.xml from Command Prompt using org.testng.TestNG
How obtain the time taken for the method to be executed TESTNG
Running dependent and independent test methods in expected sequence
TestNG: How to get the current executed group
TestNG + Groups + BeforeGroups Running Methods in alphabetical order
#BeforeTest fails but still #Test method runs
How to run test scripts in parallel machine using Selenium Grid with pom and testNG
How to get QC OTAClient dll version that registered using com4j
How to get testcase status in #Aftertest in testng
How to use #Factory annotation along with #Guice in a TestNG test class
Is a TestNG data provider parameter in setUp method possible?

Categories

HOME
xamarin
vim
clips
blogger
plot
jira
setup-deployment
electronics
jpeg
binary-tree
windows-server
serverspec
azure-media-services
azure-storage-tables
android-youtube-api
gnupg
tomcat6
nano-server
row
nstableview
ups
facebook-instant-articles
autosys
h2db
sparse-matrix
rst2pdf
web-api-testing
windowbuilder
srcset
madlib
socialengine
ioio
jspresso
noraui
vsts-build-task
hybridauth
subset-sum
xmlreader
catalog
serverside-rendering
withings
code-search-engine
hilbert-curve
dism
core-plot
glew
acoustics
reactive-cocoa-5
executenonquery
cubic-spline
xml-documentation
chain-builder
react-scripts
theming
clean-architecture
mplayer
carrot
knpmenubundle
python-cryptography
zendesk-app
deadbolt-2
py2app
jwplayer7
nsviewcontroller
make-install
google-places
atk4
libressl
pundit
drawbitmap
tableau-online
processmodel
npapi
system.reflection
offloading
ng-animate
android-imagebutton
system.net.webexception
braille
didselectrowatindexpath
meteor-velocity
message-driven-bean
dir
tidy
web2py-modules
seed
pygit2
robotics-studio
isnullorempty
first-responder
pendrive
code-cleanup
genshi
xtype
appender
recent-documents
inotifycollectionchanged
floating
lang
backcolor
swing-app-framework
project-hosting
port-number
ugc
commodore
caching-application-block

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App