Setting a test case variable in all the test cases in a Katalon Studio test suite, from the test suite - katalon-studio

This question is probably an ongoing source of complaining about Katalon Studio, but...
I have this test suite, called Discount, with 42 test cases in it. Each test case accept, as variable, a practiceProfile, with the same default value: com.xxx.profiles.PracticeProfile.SMD_DEFAULT.
Unfortunately, somewhere along the multiple runs of that test suite, I caused a blocker of a bug on the AUT, and can't run any more tests with the default profile.
I wish to install some control, in the test suite, via which I can change the practiceProfile passed to all the test cases.
I do have the following PracticeProfiles, and I know I could change it from here:
public final class PracticeProfiles {
public static final PracticeProfile SMD_DEFAULT = new PracticeProfile(OrganizationNames.SMD_BETA, PracticeNames.DEMO_PRACTICE, PracticeURLs.DEMO_PRACTICE);
public static final PracticeProfile SMD_IMPERIAL = new PracticeProfile(OrganizationNames.SMD_BETA, PracticeNames.IMPERIAL_MEDICAL_CENTER_II, PracticeURLs.IMPERIAL_MEDICAL_CENTER_II);
public static final PracticeProfile PARAGON_DEFAULT = new PracticeProfile(OrganizationNames.PARAGON, PracticeNames.PARAGON_DEMO_PRACTICE, PracticeURLs.PARAGON_DEMO_PRACTICE);
// the MDG practices
public static final PracticeProfile MDG_1 = new PracticeProfile(OrganizationNames.SMD_BETA, PracticeNames.MDG_1, PracticeURLs.MDG_1, NPINumbers.MDG_1);
public static final PracticeProfile MDG_10 = new PracticeProfile(OrganizationNames.SMD_BETA, PracticeNames.MDG_10, PracticeURLs.MDG_10, NPINumbers.MDG_10);
public static final PracticeProfile MDG_18 = new PracticeProfile(OrganizationNames.SMD_BETA, PracticeNames.MDG_18, PracticeURLs.MDG_18, NPINumbers.MDG_18);
public static final PracticeProfile MDG_19 = new PracticeProfile(OrganizationNames.SMD_BETA, PracticeNames.MDG_19, PracticeURLs.MDG_19, NPINumbers.MDG_19);
public static final PracticeProfile MDG_20 = new PracticeProfile(OrganizationNames.SMD_BETA, PracticeNames.MDG_20, PracticeURLs.MDG_20, NPINumbers.MDG_20);
public static final PracticeProfile MDG_21 = new PracticeProfile(OrganizationNames.SMD_BETA, PracticeNames.MDG_21, PracticeURLs.MDG_21, NPINumbers.MDG_21);
public static final PracticeProfile MDG_22 = new PracticeProfile(OrganizationNames.SMD_BETA, PracticeNames.MDG_22, PracticeURLs.MDG_22, NPINumbers.MDG_22);
public static final PracticeProfile MDG_23 = new PracticeProfile(OrganizationNames.SMD_BETA, PracticeNames.MDG_23, PracticeURLs.MDG_23, NPINumbers.MDG_23);
public static final PracticeProfile MDG_24 = new PracticeProfile(OrganizationNames.SMD_BETA, PracticeNames.MDG_24, PracticeURLs.MDG_24, NPINumbers.MDG_24);
public static final PracticeProfile MDG_27 = new PracticeProfile(OrganizationNames.SMD_BETA, PracticeNames.MDG_27, PracticeURLs.MDG_27, NPINumbers.MDG_27);
public static final PracticeProfile MDG_28 = new PracticeProfile(OrganizationNames.SMD_BETA, PracticeNames.MDG_28, PracticeURLs.MDG_28, NPINumbers.MDG_28);
public static final PracticeProfile MDG_40 = new PracticeProfile(OrganizationNames.SMD_BETA, PracticeNames.MDG_40, PracticeURLs.MDG_40, NPINumbers.MDG_40);
public static final PracticeProfile MDG_41 = new PracticeProfile(OrganizationNames.SMD_BETA, PracticeNames.MDG_41, PracticeURLs.MDG_41, NPINumbers.MDG_41);
public static final PracticeProfile MDG_50 = new PracticeProfile(OrganizationNames.SMD_BETA, PracticeNames.MDG_50, PracticeURLs.MDG_50, NPINumbers.MDG_50);
}
however, doing so would be incorrect.
Just a shot in the dark, is there any way I could have the test suite drive the test cases like this?

Related

Junit , Mockito Integration with Vertx

I am new vertx wanted to know which is the best junit framework and references that we should went through.
I tried using couple of things with mockito but services are not getting injected.
Please help in this.
UPDATE:
My TestClass looks something like this
public class GroupModeTest {
private static final Logger logger = LoggerFactory.getLogger(GroupMode.class);
public static GroupModeService service;
public static GroupModeDao dao;
private GroupMode groupMode;
private static GroupModeDao daoMock;
#BeforeAll
static void setup() {
logger.info("Starting Unit Tests for GroupMode");
daoMock = mock(GroupModeDao.class);
dao = new GroupModeDao();
service = new GroupModeService(daoMock);
}
#BeforeEach
void init() {
logger.info("Mocking new GroupMode Entity");
this.groupMode = new GroupMode();
}
#Test
public void testFakeWithMockito() throws IOException {
IGroupModeDao iGroupModeDao = mock(IGroupModeDao.class);
GroupMode groupMode = new GroupMode();
groupMode.setId(1L);
groupMode.setModeType("unique");
groupMode.setCreatedBy(1);
groupMode.setCreatedOn(LocalDateTime.now());
groupMode.setUpdatedBy(1);
groupMode.setUpdatedOn(LocalDateTime.now());
Single<Long> expected=Single.just(1L);
when(iGroupModeDao.create(groupMode)).thenReturn(expected);
GroupModeService groupModeService = new GroupModeService(iGroupModeDao);
Single<Long> actual= groupModeService.rxCreate("unique",1);
assertEquals(expected, actual);
}
}

Select by ResultHandler will put a empty list objcet in localCache

MyBatis version
3.5.4
Database vendor and version
MySQL 5.7.14
Test case or example project
public static final String URL = "jdbc:mysql://localhost:3306/myTest?useUnicode=true&characterEncoding=UTF-8&useSSL=false";
public static final String Driver = "com.mysql.cj.jdbc.Driver";
public static final String User_Name = "root";
public static final String Password = "";
public static void main(String[] args) {
DataSource dataSource = new PooledDataSource(Driver,URL, User_Name,Password);
TransactionFactory transactionFactory = new JdbcTransactionFactory();
Environment environment = new Environment("development", transactionFactory, dataSource);
Configuration configuration = new Configuration(environment);
configuration.addMapper(BlogMapper.class);
SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(configuration);
SqlSession sqlSession = sqlSessionFactory.openSession();
sqlSession.select("selectCount",resultContext -> {
System.out.println(resultContext.getResultCount());
System.out.println(resultContext.getResultObject());
});
Object c = sqlSession.selectOne("selectCount");
System.out.println(c);
}
public interface BlogMapper {
#Select("select count(*) from datas")
public int selectCount();
}
Steps to reproduce
Expected result
Object c = sqlSession.selectOne("selectCount");
selectOne function should retuen result ,but return null.
Actual result
sqlSession.selectOne("selectCount"); return null

Using Green DAO with content provider get error

I use GreenDao to generate ContentProvider and when I trying to use it went wrong.it tell me "DaoSession must be set during content provider is active".I dont know where to set the DaoSession.
ContentProvider class as follows
public class ContactContentProvider extends ContentProvider {
public static final String AUTHORITY = "com.junsucc.www.provider";
public static final String BASE_PATH = "contact";
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/" + BASE_PATH);
public static final String CONTENT_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE
+ "/" + BASE_PATH;
public static final String CONTENT_ITEM_TYPE = ContentResolver.CURSOR_ITEM_BASE_TYPE
+ "/" + BASE_PATH;
private static final String TABLENAME = ContactDao.TABLENAME;
private static final String PK = ContactDao.Properties.Id
.columnName;
private static final int CONTACT_DIR = 0;
private static final int CONTACT_ID = 1;
private static final UriMatcher sURIMatcher;
static {
sURIMatcher = new UriMatcher(UriMatcher.NO_MATCH);
sURIMatcher.addURI(AUTHORITY, BASE_PATH, CONTACT_DIR);
sURIMatcher.addURI(AUTHORITY, BASE_PATH + "/#", CONTACT_ID);
}
public DaoSession daoSession=BaseApplication.getDaoSession();
#Override
public boolean onCreate() {
// if(daoSession == null) {
// throw new IllegalStateException("DaoSession must be set before content provider is created");
// }
DaoLog.d("Content Provider started: " + CONTENT_URI);
return true;
}
protected SQLiteDatabase getDatabase() {
if (daoSession == null) {
throw new IllegalStateException("DaoSession must be set during content provider is active");
}
return daoSession.getDatabase();
}
......
the error as follow
java.lang.IllegalStateException: DaoSession must be set during content provider is active
at com.junsucc.www.ContactContentProvider.getDatabase(ContactContentProvider.java:71)
at com.junsucc.www.ContactContentProvider.insert(ContactContentProvider.java:83)
at android.content.ContentProvider$Transport.insert(ContentProvider.java:220)
at android.content.ContentResolver.insert(ContentResolver.java:1190)
at com.junsucc.junsucc.MD5UtilsTest.testProvider(MD5UtilsTest.java:58)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701)
but I had setted th DaoSession inside my Application
public class BaseApplication extends Application {
private static Context mContext;
private static DaoMaster mDaoMaster;
private static DaoSession mDaoSession;
public static DaoMaster getDaoMaster() {
return mDaoMaster;
}
public static Context getContext() {
return mContext;
}
#Override
public void onCreate() {
mContext = getApplicationContext();
DaoMaster.OpenHelper helper = new DaoMaster.DevOpenHelper(mContext, Constants.DB_NAME, null);
mDaoMaster = new DaoMaster(helper.getWritableDatabase());
mDaoSession = mDaoMaster.newSession();
super.onCreate();
}
}
Follow the advice of the framework
/**
* This must be set from outside, it's recommended to do this inside your Application object.
* Subject to change (static isn't nice).
*/
public static DaoSession daoSession;
In your applicaction code
#Override
public void onCreate() {
super.onCreate();
DaoMaster.OpenHelper helper = new DaoMaster.DevOpenHelper(this, Constants.DB_NAME, null);
mDaoMaster = new DaoMaster(helper.getWritableDatabase());
mDaoSession = mDaoMaster.newSession();
/***********************************************/
ContactContentProvider.daoSession = mDaoSession;
/***********************************************/
}
Because ContentProvider is created ahead of Application.
So daoSession will be null when ContentProvider created.

How to ignore a specific warning in PyDev?

How do I ignore a specific warning in Eclipse?
I am doing ZetCode's PyQt4 tutorial LPTHW style (yes, I'm using PyDev), and adding helpful comments so I can use it as a reference. Eclipse is bugging me about an unused variable. (It is being used, because the initialization function automatically runs the code. Just to be clear.)
I don't want to turn it off for the whole file, because that is actually handy in most situations. I just want to ignore that warning.
For suppressing warnings on a specific line, your only option is to add a comment such as ##UnusedVariable to the line:
def foo():
x = 5 # #UnusedVariable
return 10
To suppress a different type of warning, see the list of suppression string constants in the PyDev source code:
public static final String MSG_TO_IGNORE_TYPE_UNUSED_IMPORT = "#UnusedImport";
public static final String MSG_TO_IGNORE_TYPE_UNUSED_WILD_IMPORT = "#UnusedWildImport";
public static final String MSG_TO_IGNORE_TYPE_UNUSED_VARIABLE = "#UnusedVariable";
public static final String MSG_TO_IGNORE_TYPE_UNDEFINED_VARIABLE = "#UndefinedVariable";
public static final String MSG_TO_IGNORE_TYPE_DUPLICATED_SIGNATURE = "#DuplicatedSignature";
public static final String MSG_TO_IGNORE_TYPE_REIMPORT = "#Reimport";
public static final String MSG_TO_IGNORE_TYPE_UNRESOLVED_IMPORT = "#UnresolvedImport";
public static final String MSG_TO_IGNORE_TYPE_NO_SELF = "#NoSelf";
public static final String MSG_TO_IGNORE_TYPE_UNDEFINED_IMPORT_VARIABLE = "#UndefinedVariable";
public static final String MSG_TO_IGNORE_TYPE_UNUSED_PARAMETER = "#UnusedVariable";
public static final String MSG_TO_IGNORE_TYPE_NO_EFFECT_STMT = "#NoEffect";
public static final String MSG_TO_IGNORE_TYPE_INDENTATION_PROBLEM = "#IndentOk";
public static final String MSG_TO_IGNORE_TYPE_ASSIGNMENT_TO_BUILT_IN_SYMBOL = "#ReservedAssignment";
public static final String MSG_TO_IGNORE_TYPE_PEP8 = "#IgnorePep8";
public static final String MSG_TO_IGNORE_TYPE_ARGUMENTS_MISATCH = "#ArgumentMismatch";
For example:
def get_answer(format='string'): # #ReservedAssignment
answer = 42.0
if format == 'string':
return str(answer)
elif format == 'int':
return int(answer)
else:
return answer

Selection does not contain an applet from eclipse

When I try to run/debug this code:
package ca.kianyarand.game;
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Dimension;
import javax.swing.JFrame;
public class Game extends Canvas implements Runnable {
private static final long serialVersionUID = 1L;
public static final int WIDTH = 160;
public static final int HEIGHT = WIDTH / 12*9;
public static final int SCALE =3;
public static final String NAME = "Game";
private JFrame frame;
public boolean running = false;
public Game(){
setMinimumSize(new Dimension(WIDTH*SCALE, HEIGHT*SCALE));
setMaximumSize(new Dimension(WIDTH*SCALE, HEIGHT*SCALE));
setPreferredSize(new Dimension(WIDTH*SCALE, HEIGHT*SCALE));
frame = new JFrame(NAME);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new BorderLayout());
frame.add(this, BorderLayout.CENTER);
frame.pack();
frame.setResizable(false);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
public synchronized void start() {
running = true;
new Thread(this).start();
}
public synchronized void stop() {
running = false;
}
public void run(){
while(running){
}
}
public static void name(String []args){
new Game().start();
}
}
It comes up with 'Selection does not contain an applet' when trying to run/debug it on a Java Applet and it also comes up with 'Selection does not contain a main type' when running with a Java Application.