我在Jmeter中使用smtp采样器发送电子邮件。我遇到的问题是:它正在为每个线程组发送电子邮件。如果我的线程数= 5,那就得到5封电子邮件。如何为大量线程发送一封附有报告的电子邮件?
答案 0 :(得分:0)
使用tearDown thread group,简而言之,它更像是public class DBHelper extends DBCon {
public DBHelper(Context context){
super(context);
}
public String[] dictionaryWords(){
String query = "Select * from main_dictionary";
Cursor cursor = this.getdbconnection().rawQuery(query, null);
ArrayList<String> wordterms = new ArrayList<String>();
if(cursor.moveToFirst()){
do{
String word = cursor.getString(cursor.getColumnIndexOrThrow("main_word"));
wordterms.add(word);
}
while (cursor.moveToNext());
}
cursor.close();
String[] dictionaryWords = new String[wordterms.size()];
dictionaryWords = wordterms.toArray(dictionaryWords);
return dictionaryWords;
}
public Quizzer getQuizById(int quizId){
Quizzer quizzer = null;
String query = "select * from main_dictionary where _id =" + quizId;
Cursor cursor = this.getdbconnection().rawQuery(query, null);
if(cursor.moveToFirst()){
do{
String word = cursor.getString(cursor.getColumnIndexOrThrow("main_word"));
String tagdef = cursor.getString(cursor.getColumnIndexOrThrow("tag_definition"));
String engdef = cursor.getString(cursor.getColumnIndexOrThrow("eng_defintion"));
String sample = cursor.getString(cursor.getColumnIndexOrThrow("example"));
quizzer = new Quizzer(word, tagdef, engdef, sample);
}
while(cursor.moveToNext());
}
cursor.close();
return quizzer;
}
的{{1}}方法....
A special type of ThreadGroup可以用来执行 测试后的行动。这些线程的行为就像一个 普通的线程组元素。不同的是这些类型 线程在测试完成其常规执行后执行 线程组。
答案 1 :(得分:0)
您可以使用If Controller和__threadNum()功能触发仅针对特定线程发送电子邮件的请求。
__ threadNum()函数基本上返回当前的虚拟用户号(第一个为1,第二个为2等),因此如果将以下行放入If控制器&#34;条件&#34;面积:
${__threadNum} == 3
If Controller的子项仅针对虚拟用户3执行。
演示: